MplBubblegum.RPC (mpl_bubblegum_lib v0.1.0)
View SourceHandles RPC communication with the Solana blockchain for compressed NFT operations.
Overview
This module provides functions to interact with the Solana blockchain through RPC API calls, specifically for compressed NFT (cNFT) operations using the Digital Asset Standard (DAS) API.
Requirements
- A connection must be established with
MplBubblegum.Connection.create_connection/2
- A Helius RPC URL is required as the standard Solana RPC endpoints don't support DAS API
API Methods
The module supports the following Solana RPC methods:
sendTransaction
- Submit a signed transaction to the Solana networkgetAssetBatch
- Retrieve metadata for compressed NFTs (DAS API)getAssetProofBatch
- Retrieve merkle proofs for compressed NFTs (DAS API)
Summary
Functions
Gets asset data for a compressed NFT using the Digital Asset Standard (DAS) API.
Gets asset proof for a compressed NFT using the Digital Asset Standard (DAS) API.
Sends a signed transaction to the Solana network.
Functions
Gets asset data for a compressed NFT using the Digital Asset Standard (DAS) API.
Parameters
asset_id
- The asset ID of the compressed NFT
Returns
{:ok, asset_data}
- The asset data as a map on success{:error, reason}
- Error information on failure
Examples
case MplBubblegum.RPC.get_asset_data("4mKSoDDqApmF1DqXvVTSL7sGe1pCP2q6KomxEsYQMgZX") do
{:ok, asset_data} ->
# Process the asset data
{:error, reason} ->
# Handle the error
end
Gets asset proof for a compressed NFT using the Digital Asset Standard (DAS) API.
The proof is used to verify the authenticity and ownership of compressed NFTs stored in a merkle tree.
Parameters
asset_id
- The asset ID of the compressed NFT
Returns
{:ok, proof_data}
- The asset proof as a map on success{:error, reason}
- Error information on failure
Examples
case MplBubblegum.RPC.get_asset_proof("4mKSoDDqApmF1DqXvVTSL7sGe1pCP2q6KomxEsYQMgZX") do
{:ok, proof_data} ->
# Process the proof data
{:error, reason} ->
# Handle the error
end
Sends a signed transaction to the Solana network.
Parameters
tx_hash
- The base64-encoded transaction as a string
Returns
{:ok, signature}
- On successful transaction submission, returns the transaction signature{:error, reason}
- On failure, returns the error reason
Error Handling
Common error cases include:
- Connection not established
- Invalid RPC URL
- Network connectivity issues
- Invalid transaction format
- Transaction simulation failure (e.g., insufficient funds)
Examples
case MplBubblegum.RPC.send_transaction(signed_transaction) do
{:ok, signature} ->
# Transaction submitted successfully
# The signature can be used to check the transaction on Solana Explorer
{:error, reason} ->
# Handle error case
end