solananftmetaplex

Simulating a transaction to get fees and cost estimation


Is there a way to simulate a transaction with the Metaplex JavaScript SDK to get the cost and fees of the mint transaction?

const { nft } = await metaplex
.nfts()
.create({
    uri: "https://arweave.net/123",
    name: "My NFT",
    sellerFeeBasisPoints: 500, // Represents 5.00%.
})
.run();

Solution

  • This is not a function that is currently built in, so you would have to rely on the wallet popup to get the estimation costs.

    But an NFT will typically cost 0.011 SOL to create the onchain accounts and mint.

    Other costs would be storage costs for the offchain metadata JSON content and the image/animation, but these are extremely minimal. We are talking fraction of a US cent to upload a JSON file to Arweave, for example.

    You can use the below link to get rough Arweave costs. Units are in bytes and returns the lamports needed for the storage costs.

    https://node1.bundlr.network/price/solana/1000