Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Chain Profiles

Built-in Profiles

import sh.brane.core.chain.ChainProfiles;
 
// Ethereum Mainnet
var mainnet = ChainProfiles.ETH_MAINNET;
 
// Ethereum Sepolia Testnet
var sepolia = ChainProfiles.ETH_SEPOLIA;
 
// Local Anvil/Hardhat
var local = ChainProfiles.ANVIL_LOCAL;

Available Profiles

ProfileChain IDDefault RPC
ETH_MAINNET1Public endpoint
ETH_SEPOLIA11155111Public endpoint
ANVIL_LOCAL31337http://127.0.0.1:8545

Custom RPC URL

Override the default RPC for any built-in chain:

import sh.brane.rpc.Brane;
import sh.brane.core.chain.ChainProfiles;
 
// Connect with a custom RPC URL and chain profile
var client = Brane.builder()
    .rpcUrl("https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY")
    .chain(ChainProfiles.ETH_MAINNET)
    .build();

Custom Chain

Define your own chain profile for private networks or L2s:

import sh.brane.rpc.Brane;
import sh.brane.core.chain.ChainProfile;
import sh.brane.core.types.Wei;
 
ChainProfile myChain = ChainProfile.of(
    42161L,                            // Chain ID (Arbitrum One)
    "https://arb1.arbitrum.io/rpc",    // RPC URL
    true,                              // Supports EIP-1559?
    Wei.gwei(1)                        // Default gas price (fallback)
);
 
// Use custom chain profile with builder
var client = Brane.builder()
    .rpcUrl("https://arb1.arbitrum.io/rpc")
    .chain(myChain)
    .build();

ChainProfile Parameters

ParameterTypeDescription
chainIdlongNetwork chain ID
defaultRpcUrlStringJSON-RPC endpoint
supportsEip1559booleanUse EIP-1559 gas pricing?
defaultPriorityFeePerGasWeiDefault priority fee (for EIP-1559)

L2 Support

Brane works with any EVM-compatible chain:

// Arbitrum One
ChainProfile arbitrum = ChainProfile.of(
    42161L, "https://arb1.arbitrum.io/rpc", true, Wei.gwei(1)
);
 
// Optimism
ChainProfile optimism = ChainProfile.of(
    10L, "https://mainnet.optimism.io", true, Wei.gwei(1)
);
 
// Base
ChainProfile base = ChainProfile.of(
    8453L, "https://mainnet.base.org", true, Wei.gwei(1)
);
 
// Polygon
ChainProfile polygon = ChainProfile.of(
    137L, "https://polygon-rpc.com", true, Wei.gwei(30)
);

Using with Clients

Chain profiles integrate with the Brane client API:

import sh.brane.rpc.Brane;
import sh.brane.core.crypto.PrivateKey;
import sh.brane.core.chain.ChainProfiles;
 
// Read-only client with chain profile
Brane.Reader reader = Brane.builder()
    .rpcUrl("https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY")
    .chain(ChainProfiles.ETH_MAINNET)
    .buildReader();
 
// Full client with signer and chain profile
var signer = PrivateKey.from("0x...");
Brane.Signer client = Brane.builder()
    .rpcUrl("https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY")
    .chain(ChainProfiles.ETH_MAINNET)  // Used for chain ID in signatures
    .signer(signer)
    .buildSigner();

Chain ID Verification

Brane verifies the chain ID matches when signing transactions:

// The client uses the chain profile's ID for EIP-155 replay protection
Brane.Signer client = Brane.builder()
    .rpcUrl("https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY")
    .chain(ChainProfiles.ETH_MAINNET)  // chainId = 1
    .signer(signer)
    .buildSigner();
 
// This transaction will be signed with chainId = 1
client.sendTransaction(request);