Base URI

A base URI is stored in the smart contract and used as the URI by default for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json.

ID Substitution

The base URI must be provided when deploying the contract (or left as an empty string):

constructor(string memory baseURI_) {
    _setBaseURI(baseURI_);
 }

The base URI can be updated after deployment using _setBaseURI:

function _setBaseURI(string memory newBaseURI)

The following function returns the base URI currently set:

function _baseURI() internal view virtual returns (string memory)

Minting

The way to obtain consent from an account to get minted non-transferable tokens depends on whether the recipient is an Externally Owned Account (EOA) or a smart contract. This difference results in different function signatures - for an EOA we need to account for a signature to be passed, but not for a smart contract recipient - and ultimately different methods.

Minting to a smart contract

The smart contract recipient MUST implement the IERC1238Receiver interface and MUST respond with the “magic value” when onERC1238Mint(minter, id, amount, data) or onERC1238BatchMint(minter, ids, amounts, data) is called. This implementation makes sure that msg.sender is passed as minter.

/**
 * @dev Creates `amount` tokens of token type `id`, and assigns them to a smart contract (to).
 *
 *
 * Requirements:
 * - `to` must be a smart contract and must implement {IERC1238Receiver-onERC1238BatchMint} and return the
 * acceptance magic value.
 *
 * Emits a {MintSingle} event.
 */
function _mintToContract(
    address to,
    uint256 id,
    uint256 amount,
    bytes memory data
) internal virtual