API Reference
Complete API reference for magical-nft contracts.
Main Contract
State Variables
| Variable | Type | Description |
|---|---|---|
renderer | address | Address of the renderer contract |
storage | address | Address of the storage contract |
totalSupply | uint256 | Total number of minted tokens |
Functions
mint
function mint(address to) external payable returns (uint256)Mints a new token to the specified address.
Parameters:to- Address to receive the minted token
uint256- The ID of the newly minted token
tokenURI
function tokenURI(uint256 tokenId) public view returns (string memory)Returns the metadata URI for a token.
Parameters:tokenId- ID of the token
string- Base64-encoded JSON metadata
setRenderer
function setRenderer(address newRenderer) external onlyOwnerUpdates the renderer contract address.
Parameters:newRenderer- Address of the new renderer contract
Renderer Contract
State Variables
| Variable | Type | Description |
|---|---|---|
storageAddress | address | Address of the storage contract |
Functions
tokenURI
function tokenURI() external view returns (string memory)Generates complete token metadata JSON with embedded HTML animation and image.
Returns:string- Base64-encoded JSON metadata data URI
setStorageAddress
function setStorageAddress(address _storageAddress) external onlyOwnerUpdates the storage contract address.
Parameters:_storageAddress- Address of the new storage contract
Storage Contract
Functions
store
function store(string calldata key, bytes calldata data) external onlyOwnerStores data with a given key using SSTORE2.
Parameters:key- Identifier for the stored datadata- Raw bytes to store
read
function read(string calldata key) external view returns (bytes memory)Retrieves stored data by key.
Parameters:key- Identifier of the stored data
bytes- The stored data
getPointer
function getPointer(string calldata key) external view returns (address)Returns the SSTORE2 pointer address for a key.
Parameters:key- Identifier of the stored data
address- SSTORE2 pointer contract address
Events
Main Contract
event RendererUpdated(address indexed oldRenderer, address indexed newRenderer);Storage Contract
event DataStored(string indexed key, address pointer, uint256 size);Errors
error TokenDoesNotExist(uint256 tokenId);
error InsufficientPayment(uint256 required, uint256 sent);
error MaxSupplyReached();
error DataNotFound(string key);