πŸŒ…
Sunrise / Gluon Docs
  • Home
    • πŸ‘‹Sunrise
  • πŸ“œLearn
    • πŸŒ†Sunrise
      • Proof of Liquidity
      • Fee Abstraction
      • Data Availability
      • Gauges Voting
      • Liquidity Pool
      • Liquidity Incentive
      • Swap
      • TokenConverter
      • Fee
      • Lockup Account
      • Bribes
    • πŸ’΄$RISE
      • Allocations
    • 🏦Gluon
    • πŸ’΄$GLU
    • πŸŽ“Thesis
      • App chain thesis
      • Interoperability
  • πŸ› οΈBuild
    • πŸš€Quick Start
    • Client
    • L2 Blockchains
      • Rollkit
        • Sunrise Data
        • Rollkit L2 Chain
      • OP Stack
        • Sunrise Data
        • OP Stack L2 Chain
    • Validators
      • Proof of Data Availability
      • Self Delegation
  • πŸ—οΈRun a Sunrise Node
    • Networks
    • Types of Nodes
      • Consensus
        • Full Consensus Node
        • Validator Node (Genesis)
        • Validator Node
        • Setup Cosmovisor
      • IBC Relayers
    • Resources
      • Upgrade
      • Environment
  • πŸ—οΈRun a Gluon Node
    • Networks
    • Node
      • Validator Node
  • πŸ”—Links
    • GitHub
    • Discord
    • X (Twitter)
    • Medium
    • dev.to
  • πŸ““Deprecated (UnUniFi)
    • IBC Channels
    • Security
    • CosmWasm
      • Tutorial
      • Create Project
    • IYA Strategy
      • Interface
      • External CosmWasm chain with IBCHooks
      • External EVM chain with Axelar
    • Frontend
      • Cosmos Client TS
    • Resources
    • Setup ununifid
    • ununifid
      • Basic Commands
      • Module Commands
        • wasm
    • Build a Node
    • Build a Validator Node
    • Setup Cosmovisor
    • Mainnet Upgrades
    • IBC Relayer
Powered by GitBook
On this page
  • Available SDKs
  • JavaScript / TypeScript SDK
  • Installation
  • Basic Usage
  • Rust SDK
  • Project Structure
  • Configuration Files
  • Setup and Generation
  • Example Usage
  • Additional Resources
  • Troubleshooting
  1. Build

Client

The Sunrise client libraries let you query the chain, submit blobs and sign / broadcast transactions from your application without having to run custom protobuf tooling or hand‑craft Tendermint JSON‑RPC calls.

Available SDKs

  • JavaScript / TypeScript - Primary SDK available on npm

  • Rust - gRPC + protobuf type generation with Buf/Prost

  • Go and Python bindings - Coming soon (contributions welcome)

JavaScript / TypeScript SDK

Installation

npm install @sunriselayer/client
# or
pnpm add @sunriselayer/client
# or
yarn add @sunriselayer/client

Basic Usage

import { SunriseClient } from "@sunriselayer/client";

const RPC = "https://goldberg-rpc.sunrise.node";   // Replace with your node
const SENDER_MNEMONIC = process.env.MNEMONIC!;     // Never commit private keys

async function main() {
  // 1. Connect to the network
  const client = await SunriseClient.connect(RPC);

  // 2. Query chain parameters
  const params = await client.da.params({});
  console.log("DA params:", params);

  // 3. Submit a test blob transaction
  const signer = await SunriseClient.fromMnemonic(SENDER_MNEMONIC);
  const { transactionHash } = await client.da.submitBlob(
    "Hello Sunrise",
    { signer }
  );
  console.log("Transaction hash:", transactionHash);
}

main().catch(console.error);

All methods are fully typed when using TypeScript.

Rust SDK

The Rust SDK is currently implemented through protobuf generation. Here's how to set it up:

Project Structure

my-sunrise-client/
β”œβ”€β”€ src/
β”‚   └── main.rs
β”œβ”€β”€ buf.yaml
└── buf.gen.yaml

Configuration Files

  1. buf.yaml:

version: v2
deps:
  - buf.build/cosmos/cosmos-sdk
  - buf.build/cosmos/cosmos-proto
  - buf.build/cosmos/gogo-proto
  - buf.build/protocolbuffers/wellknowntypes
  1. buf.gen.yaml:

version: v2
managed:
  enabled: true

plugins:
  - remote: buf.build/community/neoeinstein-prost:v0.4.0
    out: src
    opt:
      - compile_well_known_types
      - extern_path=.google.protobuf=::pbjson_types
  - remote: buf.build/community/neoeinstein-prost-serde:v0.3.1
    out: src
  - remote: buf.build/community/neoeinstein-tonic:v0.4.1
    out: src
    opt:
      - compile_well_known_types
      - extern_path=.google.protobuf=::pbjson_types

inputs:
  - git_repo: https://github.com/sunriselayer/sunrise.git
    branch: main
    subdir: proto

Setup and Generation

# Add required dependencies
cargo add tonic tonic-build pbjson-types

# Update dependencies and generate code
buf dep update
buf generate

Example Usage

use tonic::transport::Channel;
use sunriselayer::sunrise::da::v1::query_client::QueryClient;
use sunriselayer::sunrise::da::v1::ParamsRequest;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let mut client = QueryClient::connect("http://localhost:9090").await?;
    let resp = client.params(ParamsRequest {}).await?;
    println!("DA params: {:?}", resp.into_inner());
    Ok(())
}

Additional Resources

Troubleshooting

Problem
Solution

Connection refused

Verify RPC URL and ensure DA node is running

Authentication error

Ensure account has sufficient funds

Rust build failure

Update to Rust 1.74+ and run cargo clean && buf generate

PreviousQuick StartNextL2 Blockchains

Last updated 5 days ago

πŸ› οΈ
Full JavaScript Method Reference
Rollup Integration Examples
Data Availability Proofs