Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

API Reference

Complete API reference for magical-nft contracts.

Main Contract

State Variables

VariableTypeDescription
rendereraddressAddress of the renderer contract
storageaddressAddress of the storage contract
totalSupplyuint256Total 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
Returns:
  • 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
Returns:
  • string - Base64-encoded JSON metadata

setRenderer

function setRenderer(address newRenderer) external onlyOwner

Updates the renderer contract address.

Parameters:
  • newRenderer - Address of the new renderer contract

Renderer Contract

State Variables

VariableTypeDescription
storageAddressaddressAddress 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 onlyOwner

Updates 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 onlyOwner

Stores data with a given key using SSTORE2.

Parameters:
  • key - Identifier for the stored data
  • data - 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
Returns:
  • 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
Returns:
  • 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);