Skip to content

Sovereign-Labs/sovereign-sdk-web3-js

Repository files navigation

Sovereign SDK Web3.js

CI codecov License pnpm

JavaScript/TypeScript SDK for interacting with Sovereign SDK rollups. This monorepo contains packages that provide type-safe transaction submission, signing capabilities, and rollup type serialization/deserialization.

Package Version Description
@sovereign-sdk/web3 npm version Primary client library for interacting with Sovereign SDK rollups
@sovereign-sdk/signers npm version Signer interface and implementations (e.g. MetaMask Snap)
@sovereign-sdk/universal-wallet-wasm npm version WebAssembly bindings for human readable byte representation and serialization/deserialization
@sovereign-sdk/modules npm version Convenient helpers for interacting with core Sovereign SDK modules
@sovereign-sdk/test npm version Testing utilities for Sovereign SDK rollups, including soak testing and transaction generation
@sovereign-sdk/utils npm version Common utilities and helper functions for Sovereign SDK development

Features

  • 🔄 Type-safe transaction submission and signing
  • 🔍 Runtime call simulation for gas estimation
  • 📦 Borsh serialization & human readable byte representation
  • 🎯 Strongly typed rollup interactions
  • 🌐 Full access to ledger, sequencer, and rollup APIs

Quick Start

A quick example of submitting a transaction to a Sovereign SDK rollup using Sovereign's universal MetaMask Snap as the wallet/signer.

# Install the main web3 package
npm install @sovereign-sdk/web3

# For MetaMask Snap support
npm install @sovereign-sdk/signers

Usage:

import { StandardRollup } from "@sovereign-sdk/web3";
import { Secp256k1Signer } from "@sovereign-sdk/signers";

// Initialize the rollup client
const rollup = new StandardRollup({
  url: "https://your-rollup-node.com",
});
// If your rollup is using ethereum style addresses/keypairs
const signer = new Secp256k1Signer(process.env.PRIVATE_KEY);

// Submit a transaction
// Sends a `ValueSetter` call message of `SetValue` type.
// This particular call message has `value` and `gas` fields.
const result = await rollup.call(
  {
    value_setter: {
      set_value: {
        value: 100,
        gas: null,
      },
    },
  },
  { signer }
);

Development

This project uses pnpm for package management and Changesets for versioning.

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run tests
pnpm test

# Format and lint
pnpm run fix

For detailed development instructions, see DEVELOPMENT.md.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Security

For security concerns, please open an issue or contact us directly. We take security issues seriously and will respond promptly.

About

Sovereign SDK Web3 library for TypeScript & JavaScript projects

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 10

Languages