Download audit report
This document presents the security review performed by Nethermind Security for Realio Districts smart contracts. Districts is a decentralized, open-source virtual world. Designed with creative professionals in mind, Districts offers a unique space for everyone to claim land and shape the future of virtual experience.
The reviewed contracts allow users to mint, buy and earn rewards from the LandPixel NFTs. The contracts also include a Marketplace where users can trade their NFTs through direct sells or auctions.
The audit comprises 1414 lines of solidity code. The audit was performed using (a) manual analysis of the codebase, (b) automated analysis tools, and (c) creation of test cases.
| Audit assessment | |
| Audit Type | Security Review |
| Initial Report | February 26, 2025 |
| Final Report | March 12, 2025 |
| Repository | districts-smart-contracts |
| Commit | b0c0a6e73c |
| Final Commit | 2f10821ad6 |
| Documentation | README, Docs |
| Documentation Assessment | High |
| Test Suite Assessment | Medium |
Findings by severity
| # | Finding | Severity | Update |
| 1 | Reentrancy in makeOffer function allows attackers to drain funds in Marketplace | Critical | Fixed |
| 2 | Incorrect Computation of User Rewards | High | Fixed |
| 3 | buyNow(...) function does not check if the listing has expired | Medium | Fixed |
| 4 | buyNow function can be front-run by sellers | Medium | Fixed |
| 5 | acceptOffer function can be front-run | Medium | Fixed |
| 6 | Users can bid with the same amount if highestBid is too low | Low | Fixed |
| 7 | buyNow(...) function does not use the correct buy now price | Low | Fixed |
| 8 | mintLandPixels cannot be executed after reaching reward allocation | Low | Fixed |
| 9 | Marketplace receives zero fees if paid amount is too low | Info | Fixed |
| 10 | ReentrancyGuard uses default storage assignment | Best Practices | Fixed |
| 11 | validPaymentToken modifier should use whitelist to validate tokens | Best Practices | Fixed |
The Districts platform is a set of smart contracts, built on the Realio Network, EVM (Ethereum Virtual Machine). The project focuses on allowing users to claim scarce parcels of land within the ecosystem via the minting of “Land Pixels” NFTs, and to gain governance rights within the ecosystem via the mining of DSTRX governance tokens. Additionally, owners of "Land Pixels" NFTs can list and trade their assets on the LandPixelMarketplace contract, which is designed to automatically direct collected fees to the “Land Bank” treasury.

The Land Bank is an ERC-2535 Diamond contract, which owns (and thus can mint) the DSTRXToken contract. It also controls the minting of LandPixel NFTs, allowing users to purchase digital land represented as NFTs with diminishing DSTRX token rewards. The system supports both direct minting of new pixels and trading of existing pixels through a floor price mechanism backed by the contract’s treasury. Users interact with Land Bank through these primary facets:
LandBankMainFacet contains most user-facing functions for interacting with the LandBank. It handles the minting, buying, and selling of LandPixels. The initial mint of Land Pixels distributes DSTRX as a reward. Main functions:
LandBankStakingFacet contains user-facing staking-related code and methods. It handles the staking, unstaking of LandPixel NFTs and staking reward distribution. Stakers earn DSTRX tokens as a reward for LandPixel staking. To determine staking rewards, the contract employs an accumulator pattern, tracking rewards dynamically as they accrue over time. Main functions:
LandBankAdminFacet includes the administrative functions for configuring and managing the LandBank settings. It also provides functionality to withdraw both native and ERC20 tokens from the contract. Main functions:
The LandPixel NFT contract is an Enumerable ERC721 ERC-2535 Diamond contract, where the LandBank serves as the only authorized minter. Each LandPixel is uniquely identified by a positive number or index, determined by the sequence in which Districts regions are released. The tokenURI links to the complete NFT metadata and must consistently follow OpenSea Metadata Standards; it is currently set to a fixed value. Users interact with LandPixel through the LandPixelFacet contract:
LandPixelFacet implements the standard ERC721 interface with extra functions to enumerate minted NFTs. LandPixel NFTs owners can freely transfer their NFTs for use within the Districts ecosystem or in external applications like OpenSea. Main functions:
LandPixelMarketplace contract supports listing and trading LandPixel NFTs, set up to automatically fund the LandBank treasury from collected fees. The collected fees in native token will increase the floor price of tokens in the LandBank contract. LandBank’s logic remains independent of Marketplace specifics, allowing the deployment of multiple Marketplace contracts or instances, each configured to direct its fee revenue to the LandBank vault or treasury. Main functions:
UnlockDistrictVote contract enables a token-based governance system to unlock districts in the LandBank ecosystem, using DSTRX tokens as voting power. It implements a threshold-based voting mechanism with partial token burning upon successful district unlocks.
The LandBank staking system implements a diminishing rewards model based on the remaining token supply, with rewards distributed proportionally among staked LandPixel NFTs.
The risk rating methodology used by Nethermind Security follows the principles established by the OWASP Foundation. The severity of each finding is determined by two factors: Likelihood and Impact.
Likelihood measures how likely the finding is to be uncovered and exploited by an attacker. This factor will be one of the following values:
When defining the likelihood of a finding, other factors are also considered. These can include but are not limited to motive, opportunity, exploit accessibility, ease of discovery, and ease of exploit.
Impact is a measure of the damage that may be caused if an attacker exploits the finding. This factor will be one of the following values:
When defining the impact of a finding, other factors are also considered. These can include but are not limited to data and state integrity, loss of availability, financial loss, and reputation damage. After defining the likelihood and impact of an issue, the severity is determined according to the table below.
| Impact / Likelihood | Low | Medium | High |
| High | Medium | High | Critical |
| Medium | Low | Medium | High |
| Low | Info / Best Practices | Low | Medium |
| Undetermined | Undetermined | Undetermined | Undetermined |
To address issues that do not fit a High, Medium or Low severity, Nethermind Security also uses three more finding severities: Informational, Best Practices, and Undetermined.
| File | Fix commit | Type | Status |
contracts/Marketplace.sol | 6e78bbd | Critical | Fixed |
The makeOffer function in the Marketplace.sol contract is vulnerable to a reentrancy attack because it does not use a reentrancy guard (e.g., the nonReentrant modifier). The issue arises in the following scenario:
* When a user makes an offer (via makeOffer), the contract first checks if an existing offer is active. If so, it refunds the existing offer by adding its amount to escrowBalances.
* The function then calls an external contract via IERC20(paymentToken).safeTransferFrom(msg.sender, address(this), amount).
* Since paymentToken is provided by the caller, an attacker could supply a malicious token contract that implements a reentrant fallback. When this external call is made, the malicious token could trigger a reentrant call to makeOffer before the state has been fully updated.
* By repeatedly reentering the function, the attacker can increase the escrowBalances for their address, enabling them to eventually withdraw more funds than they originally deposited and drain funds from the Marketplace.
The vulnerability specifically occurs because the state update (saving the new offer) happens after the external call, which violates the checks-effects-interactions pattern and leaves the contract exposed.
The problematic portion of the code is as follows:
function makeOffer(
uint256 tokenId,
uint256 duration,
address paymentToken,
uint256 amount
) external payable validDuration(duration) validPaymentToken(paymentToken) {
require(landPixelContract.ownerOf(tokenId) != msg.sender, "Cannot self-offer");
// Check for existing offer from this user
Offer storage existingOffer = offers[tokenId][msg.sender];
if (existingOffer.active) {
// Refund existing offer first
if (existingOffer.paymentToken == address(0)) {
escrowBalances[msg.sender][address(0)] += existingOffer.amount;
} else {
escrowBalances[msg.sender][existingOffer.paymentToken] += existingOffer.amount;
}
}
// Handle payment
if (paymentToken == address(0)) {
require(msg.value == amount, "Incorrect ETH amount");
} else {
require(msg.value == 0, "ETH not accepted");
require(amount > 0, "Amount must be > 0");
//@audit Reentrant function call.
IERC20(paymentToken).safeTransferFrom(msg.sender, address(this), amount);
}
// Create new offer
offers[tokenId][msg.sender] = Offer({
offerer: msg.sender,
amount: amount,
startTime: block.timestamp,
duration: duration,
active: true,
paymentToken: paymentToken
});
emit OfferMade(tokenId, msg.sender, amount, paymentToken);
}Recommendation
Add the nonReentrant modifier (from OpenZeppelin’s ReentrancyGuard) to the makeOffer function to prevent reentrant calls. For example:
function makeOffer(
uint256 tokenId,
uint256 duration,
address paymentToken,
uint256 amount
) external payable nonReentrant validDuration(duration) validPaymentToken(paymentToken) {
// ... remaining logic ...
}Resolution
Fixed in commit 6e78bb
| File | Fix commit | Type | Status |
contracts/facets/LandBankMainFacet.sol | cd21c69 | High | Fixed |
The contract tracks the cumulative rewards earned per NFT using the accumulatedRewardsPerShare variable. This variable is crucial for determining the rewards accrued by each user.
The expected behavior is that accumulatedRewardsPerShare should be updated whenever the per-block rewards change. The per-block rewards are determined by: a) The number of staked NFTs. b) The total rewards per block, which depends on remainingAllocation.
However, the contract fails to update accumulatedRewardsPerShare when remainingAllocation changes, leading to incorrect reward calculations. As a result, users may receive inaccurate rewards, potentially causing discrepancies in the reward distribution.
Recommendation
Ensure that accumulatedRewardsPerShare is updated whenever remainingAllocation or the number of staked NFTs changes to maintain accurate reward calculations.
Resolution
Fixed in commit cd21c6
buyNow(...) function does not check if the listing has expired| File | Fix commit | Type | Status |
contracts/Marketplace.sol | 0e72ee9 | Medium | Fixed |
The buyNow(...) function is used to purchase tokens listed with either:
SellType == FixedPrice, or;SellType == Auction when buyNowPrice != 0;Each listing has a defined lifespan, determined by its duration and the timestamp when it was created. However, the buyNow(...) function does not check whether the listing has expired.
This can lead to two unintended behaviors:
1. Fixed-Price listings: Users can still purchase a listing even after its valid duration has passed; 2. Auction listings: Users can directly buy a token using buyNowPrice, even if the auction has ended, as long as finalizeAuction(...) has not been called;
Recommendation
Consider validating the listing’s lifespan within the buyNow(...) function to ensure purchases are only allowed if the listing is still active.
Resolution
Fixed in commit 0e72ee.
buyNow function can be front-run by sellers| File | Fix commit | Type | Status |
contracts/Marketplace.sol | a500865 | Medium | Fixed |
When an NFT marketplace listing is placed, the seller can optionally set a buy now price. For SaleType.Auction sales, the buyNowPrice parameter is used as the buy now price. For SaleType.FixedPrice sales, highestBid parameter is used as the buy now price.
function listForSale(
uint256 tokenId,
uint256 startingPrice,
SaleType saleType,
uint256 duration,
uint256 buyNowPrice,
address paymentToken
) external validDuration(duration) validPaymentToken(paymentToken) {
//... REDACTED FOR BREVITY ...
listings[tokenId] = Listing({
saleType: saleType,
seller: msg.sender,
highestBidder: msg.sender,
highestBid: startingPrice,
startTime: block.timestamp,
duration: duration,
active: true,
// Buy now price is set here
buyNowPrice: buyNowPrice,
paymentToken: paymentToken,
escrowedAmount: 0
});By calling the buyNow function with the corresponding tokenId, buyer can purchase the NFT token immediately without waiting for auction to happen.
function buyNow(uint256 tokenId) external payable nonReentrant {
Listing storage listing = listings[tokenId];
require(msg.sender != listing.seller, "Cannot buy own listing");
require(listing.active, "Not for sale");
//... REDACTED FOR BREVITY ...
}Notice that only tokenId is taken as a function argument in the buyNow function. Since the buyers only specify the tokenId they are purchasing, this can lead to front-running attacks where the seller can change the buy now price before the purchase is made. This is possible because sellers can unlist the NFT and re-list again with different buy now prices. This is only possible for SaleType.FixedPrice type sales as only those types of listing are allowed to be unlisted. Here’s a sample attack scenario:
1. Seller creates a market listing using the listForSale function setting sale type -> SaleType.FixedPrice; 2. Buyer notices the listing and calls buyNow function with the tokenId in the first step; 3. Seller front-runs the buyNow transaction and first calls the unlist function and then calls listForSale function with different buy now prices; 4. Buyer’s buyNow transaction goes through and purchase is made for a much higher price than buyer intended;
Recommendation
Each listing created via the listForSale function should have a unique id. After a listing is created, they should be immutable. Users should use the unique listing ids to interact with the protocol.
Resolution
Fixed in commit a50086.
| File | Fix commit | Type | Status |
contracts/Marketplace.sol | 49bdd5c | Medium | Fixed |
In the Marketplace contract, Landpixel NFT owners can auction their NFTs or accept offers made to their NFTs. If an offer is made to a Landpixel NFT, the NFT owner will call the acceptOffer(uint256 tokenId, address offerer) function to accept the offer.
function acceptOffer(uint256 tokenId, address offerer) external nonReentrant {
require(landPixelContract.ownerOf(tokenId) == msg.sender, "Not the token owner");
Offer storage offer = offers[tokenId][offerer];
require(offer.active, "Offer inactive");
require(block.timestamp < offer.startTime + offer.duration, "Offer expired");
uint256 amount = offer.amount;
address paymentToken = offer.paymentToken;
// Deactivate the accepted offer
offer.active = false;
// Calculate fees
uint256 feeAmount = (amount * marketplaceFee) / 10000;
uint256 sellerAmount = amount - feeAmount;
// Transfer NFT
landPixelContract.transferFrom(msg.sender, offerer, tokenId);
// Transfer payment
if (paymentToken == address(0)) {
(bool success, ) = payable(msg.sender).call{value: sellerAmount}("");
require(success, "Seller payment failed");
(bool feeSuccess, ) = payable(landBank).call{value: feeAmount}("");
require(feeSuccess, "Fee transfer failed");
} else {
IERC20(paymentToken).safeTransfer(msg.sender, sellerAmount);
IERC20(paymentToken).safeTransfer(landBank, feeAmount);
}
emit SaleFinalized(tokenId, offerer, amount, paymentToken);
}However, the contract doesn’t account for the fact that offers can be changed after they’re made. This means a malicious buyer could change their offer right before the NFT owner accepts it, potentially lowering the offer after the owner has already agreed to the original terms. Imagine the following attack scenario:
1. Attacker makes an offer to a Landpixel NFT via makeOffer(...) function; 2. NFT owner accepts the offer by calling acceptOffer(...) and publishes tx onchain; 3. Attacker front-runs the NFT owner’s transaction and updates the offer with makeOffer(...) function; 4. NFT owner’s acceptOffer(...) is executed and owner sells their NFT for less than agreed amount;
Recommendation
Track offers by storing unique identifiers. Each offer should have a unique identifier so the NFT owner can accept without taking a risk.
Resolution
Fixed in commit 49bdd5.
highestBid is too low| File | Fix commit | Type | Status |
contracts/Marketplace.sol | 07ee7c191bb48b | Low | Fixed |
In the Marketplace contract, users can place bids on listings with SaleType == Auction. The contract enforces that each new bid must exceed the previous highestBid by a percentage of it, using the following calculation:
...
uint256 minBid = listing.highestBid + ((listing.highestBid * MIN_BID_INCREMENT_BPS) / 10000);
require(bidAmount >= minBid, "Bid too low");
...However, if listing.highestBid * MIN_BID_INCREMENT_BPS results in a value lower than 10000, the division by 10000 will round down to zero (in integer division). As a result, minBid will be equal to highestBid, allowing users to place bids at the same price.
This behavior can lead to auction sniping, where a bidder submits a last-minute bid at the same price as the current highest bid, potentially undermining the intended competitive bidding process.
Recommendation
Consider modifying the bid enforcement logic to ensure minBid is always strictly greater than highestBid. Possible solutions include:
minBid from equaling highestBid;bidAmount > highestBid in the require statement;Resolution
Fixed in commit 07ee7c.
Update from Nethermind Security
This wrongly enforces the bidAmount to be strictly bigger than minBid always. bidAmount should be strictly higher than previous bid, but greater or equal to minBid
Update from the client
Fixed in commit 91bb48.
buyNow(...) function does not use the correct buy now price| File | Fix commit | Type | Status |
contracts/Marketplace.sol | e13dc9c | Low | Fixed |
In the buyNow(...) function, buy now price is different depending on the SaleType:
uint256 price = listing.saleType == SaleType.FixedPrice ? listing.highestBid : listing.buyNowPrice;SaleType.FixedPrice, highestBid is used as the price;SaleType.Auction, buyNowPrice is used as the price;This can lead to ambiguity for the users and they might assume the incorrect buy now price is valid. A seller can put a very high highestBid price and a very low buyNowPrice for a fixed price sale. The users might assume the buyNowPrice is what they’ll pay. However, they’ll pay the highestBid price and will pay more than they intended.
Recommendation
Only use the buyNowPrice in the buyNow function.
Resolution
Fixed in commit e13dc9.
mintLandPixels cannot be executed after reaching reward allocation| File | Fix commit | Type | Status |
contracts/facets/LandBankMainFacet.sol | 9c6eff0 | Low | Fixed |
The mintLandPixels(...) function allows users to mint new NFTs by paying the pixelCost per NFT. In return, users receive both the NFT and DSTRX rewards.
However, if minting a new NFT would cause the total user rewards allocation to be exceeded, the function reverts, preventing any further minting. This makes it impossible to mint new NFTs even if users are willing to forgo rewards.
Recommendation
Modify the function logic to allow minting even when the user rewards allocation is exhausted. Instead of reverting, conditionally distribute rewards based on the remaining allocation.
Resolution
Fixed in commit 9c6eff.
| File | Fix commit | Type | Status |
contract/Marketplace.sol | 0cbb98e | Info | Fixed |
The Marketplace contract gets a fee from every sell done through it and send it to the LandBank contract.
// Calculate fees
// @audit - Fee computation rounds down
uint256 feeAmount = (amount * marketplaceFee) / 10000;
uint256 sellerAmount = amount - feeAmount;If the price of the sell is to low, the computation of the fees will round towards zero making the fee amount zero.
Recommendation
Consider rounding up if fees must be enforced.
Resolution
Fixed in commit 0cbb98.
| File | Fix commit | Type | Status |
contracts/facets/LandBankMainFacet.solcontracts/facets/LandBankStakingFacet.sol | 3e80577 | Best Practices | Fixed |
The protocol follows the Diamond Pattern, where storage slots are managed using a structured domain-based algorithm to prevent conflicts. However, the ReentrancyGuard contract does not follow this pattern and is instead inherited in two facets:
LandBankMainFacet;LandBankStakingFacet;Since ReentrancyGuard relies on Solidity’s default storage assignment, it introduces a risk of storage collisions in future upgrades, especially as new facets are added or modified.
Recommendation
Adapt the ReentrancyGuard contract to use the same structured slot assignment as the rest of the protocol. The upgradeable version of ReentrancyGuard already follows this pattern and can be used as a reference.
Resolution
Fixed in commit 3e8057.
validPaymentToken modifier should use whitelist to validate tokens| File | Fix commit | Type | Status |
contracts/Marketplace | c817f93 | Best Practices | Fixed |
While creating a listing using listForSale or making a offer using makeOffer, the users are allowed to set paymentToken to any address as long as the address is a smart contract. Later in those functions, external calls are made to the paymentToken address to interact with the tokens. While this approach offers freedom to the users to choose any token they want, it also opens a significant attack surface to the attackers. One of the attacks that this issue can lead to is already explained in the Reentrancy in makeOffer function allows attackers to drain funds in Marketplace issue.
One of the potential issues that this can lead to could be setting paymentToken address to a LandPixel NFT address in the listForSale function. If the bidders are LandPixel NFT owners and if they set the bidAmount to an NFT id that they own, they can inadvertently transfer their NFTs to the Marketplace contract with no way to get that back. Relevant code piece:
function bid(uint256 tokenId, uint256 bidAmount) external payable nonReentrant {
// REDACTED FOR BREVITY
// Handle payments first (CEI pattern)
if (listing.paymentToken == address(0)) {
require(msg.value == bidAmount, "Incorrect ETH amount");
} else {
require(msg.value == 0, "ETH not accepted");
// Transfer tokens to escrow
//@audit Here the paymentToken can be LandPixel NFT and not ERC20. This would cause NFT to be locked in the contract.
IERC20(listing.paymentToken).safeTransferFrom(msg.sender, address(this), bidAmount);
}Another potential issue is using fee-on-transfer tokens as paymentToken. In that scenario, the fee-on-transfer token would incur fees during the transfer function. This could lead to miscalculation of actual token amounts held in the Marketplace contract. These type of tokens shouldn’t be allowed to be used in the Marketplace.
Recommendation
We recommend adding a token whitelisting logic. Only allowed tokens should be used in the Marketplace.
Resolution
Fixed in commit c817f9.
Software documentation refers to the written or visual information that describes the functionality, architecture, design, and implementation of software. It provides a comprehensive overview of the software system and helps users, developers, and stakeholders understand how the software works, how to use it, and how to maintain it. Software documentation can take different forms, such as user manuals, system manuals, technical specifications, requirements documents, design documents, and code comments. Software documentation is critical in software development, enabling effective communication between developers, testers, users, and other stakeholders. It helps to ensure that everyone involved in the development process has a shared understanding of the software system and its functionality. Moreover, software documentation can improve software maintenance by providing a clear and complete understanding of the software system, making it easier for developers to maintain, modify, and update the software over time. Smart contracts can use various types of software documentation. Some of the most common types include:
These types of documentation are essential for smart contract development and maintenance. They help ensure that the contract is properly designed, implemented, and tested, and they provide a reference for developers who need to modify or maintain the contract in the future.
The Realio Districts protocol has documentation explaining its product. Beyond public documentation, they have provided a Readme file explaining the architecture of the multiple contracts and the responsibilities of each of them. In addition to this, the team was available to answer any questions raised during the engagement.
As auditors, we recommend that any changes or updates made to the audited codebase undergo a re-audit or security review to address potential vulnerabilities or risks introduced by the modifications. By conducting a re-audit or security review of the modified codebase, you can significantly enhance the overall security of your system and reduce the likelihood of exploitation. However, we do not possess the authority or right to impose obligations or restrictions on our clients regarding codebase updates, modifications, or subsequent audits. Accordingly, the decision to seek a re-audit or security review lies solely with you.
This report is based on the scope of materials and documentation provided by you to Nethermind in order that Nethermind could conduct the security review outlined in 1. Executive Summary and 2. Audited Files. The results set out in this report may not be complete nor inclusive of all vulnerabilities. Nethermind has provided the review and this report on an as-is, where-is, and as-available basis. You agree that your access and/or use, including but not limited to any associated services, products, protocols, platforms, content, and materials, will be at your sole risk. Blockchain technology remains under development and is subject to unknown risks and flaws. The review does not extend to the compiler layer, or any other areas beyond the programming language, or other programming aspects that could present security risks. This report does not indicate the endorsement of any particular project or team, nor guarantee its security. No third party should rely on this report in any way, including for the purpose of making any decisions to buy or sell a product, service or any other asset. To the fullest extent permitted by law, Nethermind disclaims any liability in connection with this report, its content, and any related services and products and your use thereof, including, without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement. Nethermind does not warrant, endorse, guarantee, or assume responsibility for any product or service advertised or offered by a third party through the product, any open source or third-party software, code, libraries, materials, or information linked to, called by, referenced by or accessible through the report, its content, and the related services and products, any hyperlinked websites, any websites or mobile applications appearing on any advertising, and Nethermind will not be a party to or in any way be responsible for monitoring any transaction between you and any third-party providers of products or services. As with the purchase or use of a product or service through any medium or in any environment, you should use your best judgment and exercise caution where appropriate. FOR AVOIDANCE OF DOUBT, THE REPORT, ITS CONTENT, ACCESS, AND/OR USAGE THEREOF, INCLUDING ANY ASSOCIATED SERVICES OR MATERIALS, SHALL NOT BE CONSIDERED OR RELIED UPON AS ANY FORM OF FINANCIAL, INVESTMENT, TAX, LEGAL, REGULATORY, OR OTHER ADVICE.
The Leading Engineers of Blockchain Infrastructure