MplBubblegum.Transfer (mpl_bubblegum_lib v0.1.0)

View Source

Functions 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:

  1. A connection must be established using MplBubblegum.Connection.create_connection/2
  2. You must have the asset ID of the compressed NFT you want to transfer
  3. You must own the NFT you're attempting to transfer
  4. You must have sufficient SOL in your wallet to cover transaction fees

Transfer Process

The transfer process includes:

  1. Retrieving the current asset data and merkle proof from the blockchain
  2. Extracting compression-related data needed for the transfer
  3. Building and signing a transfer transaction
  4. 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

transfer(asset_id, to_address)

@spec transfer(binary(), binary()) :: binary()

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:

Examples

# Transfer an NFT to a recipient address
signature = MplBubblegum.Transfer.transfer(
  "4mKSoDDqApmF1DqXvVTSL7sGe1pCP2q6KomxEsYQMgZX",
  "3Kn6a9nJLW5324a5M3qW3xTpvnwGf7nKzBmpJVLYxfEP"
)