A library in Elixir for handling compressed NFTs (cNFTs) on Solana. Published here https://hex.pm/packages/mpl_bubblegum_nifs
Add mpl_bubblegum_nifs
to your list of dependencies in mix.exs
:
def deps do
[
{:mpl_bubblegum_nifs, "~> 0.1.0"}
]
end
Then run:
mix deps.get
Before using the library, establish a connection to Solana RPC. Use a Helius RPC URL, as native Solana RPC does not support DAS API.
MplBubblegum.Connection.create_connection(secret_key, rpc_url)
This function initializes a new Merkle tree, which is required for minting compressed NFTs.
merkle_tree = MplBubblegum.create_tree_config()
IO.puts("Tree created at: #{merkle_tree}")
To mint a cNFT, provide the Merkle tree address and metadata details.
tx = MplBubblegum.mint_v1(
"9ppyWc9LjccAJPchEoPYatZQgk5PwJgUhZi3rTd8skcE", # Merkle tree address
"Solana Warrior", # NFT Name
"SW", # Symbol
"https://bafybeih7oz5pds33io34ud5ut4fd5a2jj74zoduiec2fw4oz24yqfo4aey.ipfs.w3s.link/1034.json", # Metadata URI
250, # Seller Fee Basis Points
100 # Creator Share
)
IO.puts("Minted cNFT, tx: #{tx}")
To transfer ownership of a compressed NFT, provide the asset ID and recipient's address.
tx = MplBubblegum.transfer(
"6pfiemDtGpzFTWmT2rfNmvMAdPzvYcdzXJXquwjbB97q", # Asset ID
"6hxBtjckJxUf9FM8V9dDq1Wux5azG2a64osiNwP1KwDN" # Recipient Address
)
IO.puts("Transferred cNFT, tx: #{tx}")
Autogenerated docs can be found here https://hexdocs.pm/mpl_bubblegum_nifs/api-reference.html
This project is licensed under the MIT License.