Skip to main content

Overview

Brane is a modern, type-safe Java SDK for Ethereum. It provides a clean, fluent API for interacting with EVM, with a focus on correctness and performance.

Installation

Private Access OnlyBrane is currently in private alpha. The artifacts are not yet available on Maven Central.

For Maintainers

If you are contributing to Brane or have access to the source code, you can install the SDK locally.
  1. Clone the repository:
    git clone https://github.com/noise-xyz/brane.git
    cd brane
    
  2. Publish to local Maven:
    ./gradlew publishToMavenLocal
    
  3. Add mavenLocal() to your project’s repositories:
    <repositories>
        <repository>
            <id>local-maven</id>
            <url>file://${user.home}/.m2/repository</url>
        </repository>
    </repositories>
    

Dependencies

Once configured, add the dependencies:
<dependencies>
    <dependency>
        <groupId>com.github.noise-xyz.brane</groupId>
        <artifactId>brane-core</artifactId>
        <version>0.1.0-alpha</version>
    </dependency>
    <dependency>
        <groupId>com.github.noise-xyz.brane</groupId>
        <artifactId>brane-rpc</artifactId>
        <version>0.1.0-alpha</version>
    </dependency>
    <dependency>
        <groupId>com.github.noise-xyz.brane</groupId>
        <artifactId>brane-contract</artifactId>
        <version>0.1.0-alpha</version>
    </dependency>
</dependencies>

Usage

1. Connect to a Chain

Create a PublicClient to read from the blockchain.
import io.brane.rpc.BranePublicClient;
import io.brane.core.chain.ChainProfiles;

public class Example {
    public static void main(String[] args) {
        // Connect to Mainnet
        var client = BranePublicClient.forChain(ChainProfiles.ETH_MAINNET)
            .build();
        
        // Get the latest block number
        var block = client.getLatestBlock();
        System.out.println("Current Block: " + block.number());
    }
}

2. Send a Transaction

Create a WalletClient to sign and send transactions.
import io.brane.rpc.DefaultWalletClient;
import io.brane.rpc.BranePublicClient;
import io.brane.core.crypto.PrivateKeySigner;
import io.brane.core.types.Wei;
import io.brane.core.types.Address;

// ...

// 1. Create dependencies
var publicClient = BranePublicClient.forChain(ChainProfiles.ETH_SEPOLIA).build();
var signer = new PrivateKeySigner(System.getenv("SEPOLIA_PRIVATE_KEY"));

// 2. Create Wallet
var wallet = DefaultWalletClient.create(
    publicClient.getProvider(),
    publicClient,
    signer,
    ChainProfiles.ETH_SEPOLIA
);

import io.brane.core.builder.TxBuilder;

var request = TxBuilder.eip1559()
    .to(new Address("0x..."))
    .value(Wei.fromEther("0.01"))
    .build();

var receipt = wallet.sendTransactionAndWait(
    request,
    60_000, // timeout (ms)
    1_000   // poll interval (ms)
);

System.out.println("Tx Hash: " + receipt.transactionHash());