Playground

Mint Dynamic NFTs

Allow your users to mint new tokens into any given contract. You sponsor the gas so your users only need a wallet address!

Example

Mint ERC1155 NFTs in 0x8a4E...d6FB contract on Base Sepolia

Upload Image

Code

Code to implement above shown example

Send Transaction Request to Mint Dynamic NFTs

const chainId = 84532;
const contractAddress = "0x8a4E14591088bBce4a4Dcfa677C1af78d336d6FB";
const contract = getContract({
  address: 0x8a4e14591088bbce4a4dcfa677c1af78d336d6fb,
  chain: defineChain(84532),
  client: THIRDWEB_CLIENT,
});

const transaction = mintTo({
  contract,
  to: "0x....",
  nft: {
    name: "...",
    description: "...",
    image: "...", // ipfs or https link to your asset
  },
  supply: "1",
});

const serverWallet = Engine.serverWallet({
  address: BACKEND_WALLET_ADDRESS,
  client: THIRDWEB_CLIENT,
  vaultAccessToken: ENGINE_VAULT_ACCESS_TOKEN,
});

const { transactionId } = await serverWallet.enqueueTransaction({
  transaction,
});

Get Transaction Status

Once you send a request to mint NFTs, you can poll for the status of the transaction using the following code.

const result = await Engine.getTransactionStatus({
  client: THIRDWEB_CLIENT,
  transactionId: transactionId,
});

console.log(result.status);

// or wait for the transaction to be mined (polls status until it's mined)
const result = await Engine.waitForTransactionHash({
  client: THIRDWEB_CLIENT,
  transactionId: transactionId,
});

console.log(result.transactionHash);