| Crates.io | branchia |
| lib.rs | branchia |
| version | 0.0.1 |
| created_at | 2025-06-11 12:10:03.377528+00 |
| updated_at | 2025-06-11 12:10:03.377528+00 |
| description | A Rust implementation of the solana gill library |
| homepage | https://github.com/ubadineke/branchia |
| repository | https://github.com/ubadineke/branchia |
| max_upload_size | |
| id | 1708501 |
| size | 175,074 |
cargo add branchia
You can find some system specific helpers here
You can find transaction builders for common tasks, including:
For troubleshooting and debugging your Solana transactions, see Debug mode below.
You can also consult the documentation for Anza's JavaScript client library for more information and helpful resources.
For most "signing" transactions, you'll need a Keypair instance, which can be used to sign transactions and messages.
use branchia::{Keypair, Signer};
let signer = Keypair::new();
Ensure you import the
Signertrait as it contains necessary methods to facilitate signing
Create a Solana rpc client for any RPC URL or standard Solana network moniker (i.e. devnet, localnet, mainnet etc) with a default commitment level of confirmed
use branchia::SolanaClient;
let client = SolanaClient::new("devnet");
Using the Solana moniker will connect to the public RPC endpoints. These are subject to rate limits and should not be used in production applications. Applications should find their own RPC provider and the URL provided from them.
To create an RPC client with another commitment level:
use branchia::{SolanaClient, CommitmentConfig};
let client = SolanaClient::new_with_commitment("localnet", CommitmentConfig::processed);
To create an RPC client for an custom RPC provider or service:
use branchia::SolanaClient;
let client = SolanaClient::new("https://private-solana-rpc-provider.com");
After you have a Solana rpc connection, you can make all the JSON RPC method calls directly off of it.
use branchia::SolanaClient;
let client = SolanaClient::new("devnet");
//get slot
let slot = client.rpc.getSlot();
//get the latest blockhash
let latest_blockhash = client.rpc.get_latest_blockhash();
Quickly create a Solana transaction:
use branchia::TxBuilder;
let tx = TxBuilder::new(
fee_payer,
instructions,
// the compute budget values are HIGHLY recommend to be set in order to maximize your transaction landing rate
compute_unit_limit, //optional
compute_unit_price //optional
);
COMING SOON!
use branchia::TxBuilder;
let tx = TxBuilder::new(...);
let signed_tx = tx.sign(signers, latest_blockhash);
To simulate a transaction on the blockchain, you can use the simulate_transaction method on the initialized SolanaClient
use branchia::{...};
let client = SolanaClient::new("devnet");
let tx = TxBuilder::new(...);
let signed_tx = tx.sign(...);
let simulation = client.rpc.simulate_transaction(signed_tx);
Simulation with Custom Config: COMING SOON!
To send and confirm a transaction to the blockchain, you can use the sendAndConfirmTransaction method from the initialized SolanaClient. The default commitment level is processed, to set another level check out - COMING SOON!
use branchia::{...};
let client = SolanaClient::new("devnet");
let tx = TxBuilder::new(...);
let signed_tx = tx.sign(...);
let signature = client.rpc.send_and_confirmed_transaction(signed_tx);
Set custom config
COMING SOON!
After you have a transaction signed by the feePayer (either a partially or fully signed transaction), you can get the
transaction signature as follows:
use branchia::TxBuilder;
let tx = TxBuilder::new(...);
let signed_tx = tx.sign(...);
let signature = signed_tx.signatures[0];
Note: After a transaction has been signed by the fee payer, it will have a transaction signature (aka transaction id). This is due to Solana transaction ids are the first item in the transaction's
signaturesarray. Therefore, client applications can potentially know the signature before it is even sent to the network for confirmation.
Craft a Solana Explorer link for transactions, accounts, or blocks on any cluster.
To get an explorer link for a transaction's signature (aka transaction id):
use branchia::TxBuilder;
let url = TxBuilder::get_explorer_link_transaction(cluster, signature);
The
clusterparameter accepts custom urls and the known monikers(i.e devnet, mainnet, localnet)
If you have a partially or fully signed transaction, you can get the Explorer link before even sending the transaction to the network:
See
Get Signature from a Signed Transactionfor better understanding.
use branchia::TxBuilder;
let tx = TxBuilder::new(...);
let signed_tx = tx.sign(...);
let url = TxBuilder::get_explorer_link_transaction("localnet", &signed_tx.signatures[0].to_string())
COMING SOON!
To get an explorer link for an account on Solana's devnet:
use branchia::TxBuilder;
let url = TxBuilder::get_explorer_link_account("devnet", "Bf8PxxWt7UTvNGcrDyNwQiERSwNroa4pEo1pxwKo17Uh");
To get an explorer link for a block:
use branchia::TxBuilder;
let url = TxBuilder::get_explorer_link_block("localnet", 2345);
To calculate the minimum rent balance for an account (aka data storage deposit fee):
use branchia::Rent;
let rent = Rent::default().minimum_balance(0);
// Expected value: 890880
use branchia::Rent;
let rent = Rent::default().minimum_balance(50);
// Expected value: 1238880
use branchia::{Keypair, KeypairExt};
let signer = Keypair::from_default_file();
Ensure you import the
KeypairExttrait as it contains extended functionality on the Keypair component
Load a Keypair from a filesystem wallet json file, like those output from the Solana CLI (i.e. a JSON array of numbers).
By default, the keypair file loaded is the Solana CLI's default keypair: ~/.config/solana/id.json
To load a Signer from a specific filepath:
use branchia::Keypair;
let signer = Keypair::from_default_file(path);
Save a Keypair to a local json file(e.g keypair.json)
use branchia::Keypair;
let signer = Keypair::new();
signer.write_to_file(path);
Build a transaction that can create a token with metadata, either using the original token or token extensions (token22) program. - COMING SOON!
TOKEN_PROGRAM_ADDRESS, default) will use Metaplex's Token Metadata
program for onchain metadataTOKEN_2022_PROGRAM_ADDRESS) will use the metadata pointer
extensions - COMING SOON!
INSTRUCTION BUILDERS - COMING SOON!use branchia:{TxBuilder, MetadataArgs};
let create_token_tx = TxBuilder::create_token_transaction(
fee_payer,
latest_blockhash,
mint,
MetadataArgs{
name
symbol
uri
is_mutable // if the `updateAuthority` can change this metadata in the future
},
decimals,
tokenProgram //just the regular token program, no token 2022 support yet
)
// ADD DEFAULT VALUES FOR CERTAIN FIELDS HERE? - TBD!
Build a transaction that mints new tokens to the destination wallet address (raising the token's overall supply).
tokenProgram used by the mint itselfdestination owner does not have an associated token account (ata) created for the mint, one will be
auto-created for themdecimals for the mint when setting the amount in this transactionuse branchia::TxBuilder;
let mint_tokens_tx = TxBuilder::mint_token_transaction(
fee_payer,
latest_blockhash,
mint,
mint_authority,
amount,// note: be sure to consider the mint's `decimals` value
// if decimals=2 => this will mint 10.00 tokens
// if decimals=4 => this will mint 0.100 tokens
destination, // use the correct token program for the `mint`
token_program //just the regular token program, no token 2022 support yet
)
Build a transaction that transfers tokens to the destination wallet address from the source (aka from sourceAta to
destinationAta).
tokenProgram used by the mint itselfdestination owner does not have an associated token account (ata) created for the mint, one will be
auto-created for themdecimals for the mint when setting the amount in this transactionuse branchia::{TxBuilder}
let transfer_tokens_tx = TxBuilder::transfer_token_transaction(
fee_payer,
latest_blockhash,
mint,
authority,
amount: 900, // note: be sure to consider the mint's `decimals` value
// if decimals=2 => this will transfer 9.00 tokens
// if decimals=4 => this will transfer 0.090 tokens
destination, // use the correct token program for the `mint`
token_program
)