Playground

Mint 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 0x8CD1...80f6 contract on Base Sepolia

Upload Image

Code

Code to implement above shown example

Send Transaction Request to Mint NFTs

const chainId = 84532;
const contractAddress = "0x8CD193648f5D4E8CD9fD0f8d3865052790A680f6";
const url = `${YOUR_ENGINE_URL}/contract/${chainId}/${contractAddress}/erc1155/mint-to`;

const response = await fetch(url, {
  method: "POST",
  headers: {
    Authorization: "Bearer YOUR_SECRET_TOKEN",
    "Content-Type": "application/json",
    "X-Backend-Wallet-Address": "YOUR_BACKEND_WALLET_ADDRESS",
  },
  body: JSON.stringify({
    receiver: "0x....",
    metadataWithSupply: {
      metadata: {
        name: "...",
        description: "...",
        image: "...", // ipfs or https link to your asset
      },
      supply: "1",
    },
  }),
});

const data = await response.json();
console.log(data.queueId);

Get Transaction Status

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

function getEngineTxStatus(queueId: string) {
  const url = `${YOUR_ENGINE_URL}/transaction/${queueId}`;
  const response = await fetch(url, {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_SECRET_TOKEN",
    },
  });

  const data = await response.json();
  return data.result;
}

// you can keep polling for the status until you get a status of either "mined" or "errored" or "cancelled"
const result = await getEngineTxStatus(queueId);

console.log(result.status);