Developer Contracts Hub
Inspect, compile, and explore our production-grade smart contracts compiled with Solidity 0.8.24.
Workspace Directory
/contracts/scripts/testRoot config
Solc Compiler Simulator
Version:0.8.24+commit.e11b
Optimization:Enabled (200 runs)
EVM target:Shanghai
CyberNFT.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/token/common/ERC2981.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title CyberNFT
* @notice Standard ERC721 NFT contract with royalty support (ERC2981)
*/
contract CyberNFT is ERC721URIStorage, ERC2981, Ownable {
uint256 private _nextTokenId;
address public marketplaceAddress;
error URIEmpty();
error RoyaltyFeeTooHigh();
event NFTMinted(
uint256 indexed tokenId,
string tokenURI,
address indexed creator,
address indexed royaltyReceiver,
uint96 royaltyFeeBps
);
constructor(address _marketplaceAddress)
ERC721("CyberSpace NFT", "CYBER")
Ownable(msg.sender)
{
marketplaceAddress = _marketplaceAddress;
_setDefaultRoyalty(msg.sender, 500);
}
function mint(
string memory tokenURI,
address royaltyReceiver,
uint96 royaltyFeeBps
) public returns (uint256) {
if (bytes(tokenURI).length == 0) revert URIEmpty();
if (royaltyFeeBps > 2000) revert RoyaltyFeeTooHigh(); // max 20%
_nextTokenId++;
uint256 newItemId = _nextTokenId;
_mint(msg.sender, newItemId);
_setTokenURI(newItemId, tokenURI);
if (royaltyReceiver != address(0) && royaltyFeeBps > 0) {
_setTokenRoyalty(newItemId, royaltyReceiver, royaltyFeeBps);
}
approve(marketplaceAddress, newItemId);
emit NFTMinted(newItemId, tokenURI, msg.sender, royaltyReceiver, royaltyFeeBps);
return newItemId;
}
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721URIStorage, ERC2981)
returns (bool)
{
return super.supportsInterface(interfaceId);
}
}Local Setup & SecureChainAI Mainnet Deployment Guide
1. Clone & Install Dependencies
To run this workspace on your local terminal, install Hardhat toolkit & OpenZeppelin contracts library.
npm install --save-dev hardhat npm install @openzeppelin/contracts dotenv
2. Run Local Unit Tests
Execute Chai and Hardhat network tests to check reentrancy locks, marketplace fees, and royalty math.
npx hardhat test
3. Deploy on SecureChainAI Mainnet
Inject your private key in `.env`, and trigger deployer scripts.
npx hardhat run scripts/deploy.js --network securechain