ERC-721 NFT Development: Audit, Gas Optimization, Deployment

We design and develop ERC-721 contracts that won't break. A typical story: a project deploys a collection, only to discover a month later that royalties aren't being paid on OpenSea (because EIP-2981 wasn't implemented), metadata is loaded from a centralized server (which goes down), and minting via

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1441
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1301
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    998
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1267
  • image_logo-advance_0.webp
    B2B Advance company logo design
    713
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1003

We design and develop ERC-721 contracts that won't break. A typical story: a project deploys a collection, only to discover a month later that royalties aren't being paid on OpenSea (because EIP-2981 wasn't implemented), metadata is loaded from a centralized server (which goes down), and minting via _safeMint instead of _mint allows reentrancy through onERC721Received in custom recipient contracts. Result: loss of community trust, lawsuits, and contract rewrites. From our practice: in one project, the absence of EIP-2981 led to a 15% loss of royalties on secondary sales—about 120 ETH (~$300k). A proper ERC-721 is not just interface compliance; it's understanding how marketplaces, wallets, and aggregators interact with the contract. We offer end-to-end development with audit and support—contact us for a project assessment.

Baseline Implementation via OpenZeppelin

The starting point is ERC721 from OpenZeppelin 5.x. We don't write the standard from scratch: OZ has passed dozens of audits; any custom implementation adds risk without obvious benefit. We extend through inheritance:

contract MyNFT is ERC721, ERC721Enumerable, ERC721URIStorage, ERC2981, Ownable { uint256 private _nextTokenId; uint256 public constant MAX_SUPPLY = 10000; constructor(address initialOwner) ERC721("My Collection", "MYC") Ownable(initialOwner) {} } 

ERC721Enumerable is needed if the contract must return a list of tokens owned by an address (tokenOfOwnerByIndex). It adds ~20K gas per transfer due to additional storage operations. If the marketplace doesn't require it, it's better to omit it and read data via The Graph.

ERC721URIStorage allows storing a separate URI for each token. An alternative is the baseURI + tokenId pattern, where all tokens use a single base path. The second option is cheaper in gas during mint.

EIP-2981: Royalties at the Contract Level

_setDefaultRoyalty(royaltyReceiver, royaltyBps); // bps: 500 = 5% 

OpenSea and most modern marketplaces read royaltyInfo() from EIP-2981. Older marketplaces used an off-chain config via Operator Filter Registry—this approach is outdated. Implementing EIP-2981 is the minimum standard for any modern collection.

Important: royaltyBps is not enforced on-chain; it's an informational standard. Marketplaces may ignore it. For enforced royalties, custom transfer hooks are needed (EIP-2981 + transfer restrictions via operator whitelist).

Metadata and Storage

The token URI returns a JSON with fields name, description, image, attributes. Where to store—comparison of methods:

Method Cost Decentralization Durability Best for
IPFS Low Yes (with pinning) Requires pinning Most collections
Arweave Medium (one-time) Yes Permanent Long-term projects
On-chain High Full Permanent Generative art (<1000 tokens)
Centralized server Low No Depends on operator Pre-reveal phase

Centralized server is only for the pre-reveal phase. After reveal, the URI should switch to IPFS. We implement via a revealed flag and two baseURIs.

How to Optimize Minting and Reduce Gas?

Standard _safeMint is more expensive than _mint due to the IERC721Receiver check on contract addresses. If minting is intended only for EOA, use _mint. If contract wallets (multisig) need support, use _safeMint with an explicit reentrancy guard.

For batch minting, use ERC-721A (Azuki) instead of the standard OZ ERC-721. ERC-721A stores owner data only for the first mint in a batch; subsequent tokens are deduced—saving up to 70% in gas when minting 10+ tokens. For a collection of 10,000 tokens, this saves about 50 ETH (~$100k) in fees. Trade-off: the first token transfer in a batch is slightly more expensive due to lazy initialization.

Gas comparison of mint methods:

Method Gas per 1 mint Gas per 10 mint Reentrancy protection
_mint ~60k ~600k No
_safeMint ~80k ~800k Partial
ERC-721A ~60k ~150k No (need guard)

What Other Vulnerabilities Need to Be Closed?

Reentrancy via onERC721Received

If a recipient contract implements IERC721Receiver, it can call back into your contract during mint. Solution: use OpenZeppelin's ReentrancyGuard or _mint and check balance after transfer.

Unchecked Low-Level Calls

Avoid direct call without checking the return value. In modern Solidity, the compiler requires explicit success handling.

Process of Work

  1. Analysis (0.5-1 day). Determine supply, mint mechanics (public/whitelist/Merkle), royalties, whether Enumerable and URIStorage are needed, target chain.
  2. Design and Development (1-2 days). Write the contract in Solidity 0.8.x with tests in Foundry. Prepare deployment and verification scripts.
  3. Audit and Gas Optimization (0.5 day). Check with static analyzer Slither, fuzz testing Echidna. Optimize gas: remove redundant storage variables, use unchecked blocks.
  4. Testnet Deployment (0.5 day). Sepolia, verify interaction with marketplaces.
  5. Mainnet Deployment and Support (1 day). Verify on Etherscan, transfer ownership, monitor. Post-deployment support for 30 days.

What's Included in the Work

  • Full source code of the contract with comments.
  • Documentation on functions, events, and modifiers.
  • Deployment and verification scripts for Etherscan.
  • Instructions for setting up metadata (IPFS/Arweave).
  • Team training: checking mint, revealing.
  • Technical support for 30 days after deployment.

Advantages of Working with Us

Our team has 7+ years of experience in blockchain development, with over 50 smart contract projects completed. We don't just copy the OpenZeppelin template—we adapt each collection to specific marketplace requirements, gas limits, and distribution models. Get a consultation—send us a description of your project, and we'll estimate timelines and costs.

// Example contract with whitelist and reveal contract AdvancedNFT is ERC721, ERC2981, Ownable { using MerkleProof for bytes32[]; bytes32 public whitelistRoot; string public baseURI; string public placeholderURI; bool public revealed; uint256 public mintPrice = 0.08 ether; function whitelistMint(bytes32[] calldata proof) external payable { require(MerkleProof.verify(proof, whitelistRoot, keccak256(abi.encodePacked(msg.sender)))); _safeMint(msg.sender, _nextTokenId++); } function reveal(string memory _newBaseURI) external onlyOwner { revealed = true; baseURI = _newBaseURI; } } 

Estimated timelines: basic ERC-721 with royalties and IPFS metadata—2-3 days; with whitelist, reveal, and mint site—5-7 days. Cost is calculated individually. Order development of an ERC-721 contract with audit and support.