MplBubblegum.Transfer (mpl_bubblegum_lib v0.1.0)
View SourceFunctions for transferring compressed NFTs on Solana.
Overview
This module provides functionality to transfer ownership of compressed NFTs (cNFTs) that were created using the Metaplex Bubblegum standard. Compressed NFTs use Solana's state compression feature which allows for much lower transaction costs compared to traditional NFTs.
Prerequisites
Before transferring a compressed NFT:
- A connection must be established using
MplBubblegum.Connection.create_connection/2
- You must have the asset ID of the compressed NFT you want to transfer
- You must own the NFT you're attempting to transfer
- You must have sufficient SOL in your wallet to cover transaction fees
Transfer Process
The transfer process includes:
- Retrieving the current asset data and merkle proof from the blockchain
- Extracting compression-related data needed for the transfer
- Building and signing a transfer transaction
- Submitting the transaction to the Solana network
Example Usage
# First establish a connection with your wallet's private key
MplBubblegum.Connection.create_connection(secret_key, rpc_url)
# Then transfer the NFT
signature = MplBubblegum.Transfer.transfer(
"4mKSoDDqApmF1DqXvVTSL7sGe1pCP2q6KomxEsYQMgZX", # Asset ID
"DEF456GHI789jklMNOpqrSTUvwxYZ" # Recipient address
)
# The signature can be used to view the transaction on Solana Explorer
# https://explorer.solana.com/tx/<signature>
Summary
Functions
Transfers a compressed NFT to a new owner.
Functions
Transfers a compressed NFT to a new owner.
Parameters
asset_id
- The asset ID of the compressed NFT to transfer (string)to_address
- The wallet address of the recipient (string in base58 format)
Returns
binary()
- The transaction signature as a base58 string on success
Error Handling
This function will raise errors in the following cases:
RuntimeError
- If no connection has been establishedArgumentError
- If the asset ID or recipient address is invalidRuntimeError
- If you don't own the NFT being transferredRuntimeError
- If the asset data or proof cannot be retrievedRuntimeError
- If the transaction fails to send
Examples
# Transfer an NFT to a recipient address
signature = MplBubblegum.Transfer.transfer(
"4mKSoDDqApmF1DqXvVTSL7sGe1pCP2q6KomxEsYQMgZX",
"3Kn6a9nJLW5324a5M3qW3xTpvnwGf7nKzBmpJVLYxfEP"
)