🎮
Unity
  • 👋Unity SDK
  • ⚙️Getting Started
    • ⚙️Installation
    • Basic Concepts
  • Features and Functionality
    • 🔗Phantasma Link Client
    • ☁️PhantasmaAPI
    • 📝Scriptbuilder
  • Tutorials and Examples
    • 🖥️Examples
      • Get Account Balances
      • Send a Transaction
      • Get Transaction by Hash
      • Get NFT
      • Get Multiple NFTs
      • Invoke Raw Script
      • Mint an NFT
      • Update an NFT's RAM
      • Burn an NFT
      • Send an NFT
      • Infuse an NFT
      • Mint Tokens
      • Burn Tokens
      • Transfer Tokens
      • Logging in to the Wallet
    • 📹Tutorials
  • Resources
    • 👻About Phantasma
    • 👻Getting Started
    • 🧑‍🤝‍🧑For new Soldiers
    • 👨‍💻For Developers
Powered by GitBook
On this page
  1. Tutorials and Examples
  2. Examples

Burn an NFT

This example demonstrates how to burn an NFT, permanently removing it from the Phantasma blockchain. A transaction script is created and sent using the SendTransaction() method from the PhantasmaLinkClient class.

public void BurnNFT()
{
    if (!PhantasmaLinkClient.Instance.IsLogged) return;

    ScriptBuilder sb = new ScriptBuilder();
    var userAddress = Address.FromText(PhantasmaLinkClient.Instance.Address);
    var toAddress = Address.FromText("P2KKEjZK7AbcKZjuZMsWKKgEjNzeGtr2zBiV7qYJHxNXvUa");
    var symbol = "CROWN";
    var id = new BigInteger("1000000000000");
    var payload = Base16.Decode("OurDappExample");
    var script = sb.AllowGas(userAddress, Address.Null, PhantasmaLinkClient.Instance.GasPrice, PhantasmaLinkClient.Instance.GasLimit ).
        CallInterop("Runtime.BurnToken", userAddress, symbol, id).
        SpendGas(userAddress).
        EndScript();
    
    PhantasmaLinkClient.Instance.SendTransaction("main", script, payload, (hash, s) =>
    {
        if ( hash.IsNull )
        {
            Debug.Log("Transaction failed: " + s);
            return;
        }
        
        Debug.Log("Transaction sent: " + hash);
    });
}
PreviousUpdate an NFT's RAMNextSend an NFT

Last updated 2 years ago

🖥️