MplBubblegum.Connection (mpl_bubblegum_lib v0.1.0)
View SourceManages the connection to Solana RPC for Bubblegum NFT interactions.
Connection Setup
Before using any functionality in the MplBubblegum library, you must establish
a connection to a Solana RPC endpoint using create_connection/2
.
Helius RPC Requirement
IMPORTANT: You must use a Helius RPC URL (https://helius.xyz) as your RPC endpoint. Standard Solana RPC nodes do not support the Digital Asset Standard (DAS) API, which is required for compressed NFT operations.
Example Usage
# Initialize the connection
secret_key = "your_wallet_private_key"
rpc_url = "https://your-helius-rpc-endpoint.helius.xyz/..."
MplBubblegum.Connection.create_connection(secret_key, rpc_url)
# Now you can use other MplBubblegum functions
Summary
Functions
Returns a specification to start this module under a supervisor.
Creates a new connection with the given secret key and RPC URL.
Returns the stored RPC URL.
Returns the stored secret key.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
Creates a new connection with the given secret key and RPC URL.
Parameters
secret_key
- The private key of your Solana wallet as a binary stringrpc_url
- The Helius RPC endpoint URL as a binary string
Returns
{:ok, pid}
- If the connection was successfully created{:error, reason}
- If the connection could not be established
Examples
MplBubblegum.Connection.create_connection(
"your_wallet_private_key",
"https://your-helius-rpc-endpoint.helius.xyz/..."
)
Error Handling
Will raise an ArgumentError
if the connection has already been established.
If you need to change the connection details, restart your application.
@spec get_rpc_url() :: binary()
Returns the stored RPC URL.
Returns
binary()
- The RPC URL provided during connection setup
Error Handling
Will raise a RuntimeError
if called before establishing a connection
with create_connection/2
.
Examples
rpc_url = MplBubblegum.Connection.get_rpc_url()
@spec get_secret_key() :: binary()
Returns the stored secret key.
Returns
binary()
- The secret key provided during connection setup
Error Handling
Will raise a RuntimeError
if called before establishing a connection
with create_connection/2
.
Examples
secret_key = MplBubblegum.Connection.get_secret_key()