TypeScript SDK

Viem-based contract bindings for SVRN Chain. Type-safe interactions with every protocol contract.

Installation

npm install @svrn/sdk viem

Quick Start

Initialize Client
import { createPublicClient, http } from 'viem';
import { svrnChain } from '@svrn/sdk';
import { depositUSDC } from '@svrn/sdk/bridge';

const client = createPublicClient({
  chain: svrnChain,
  transport: http(),
});
Bridge Deposit
import { createWalletClient, custom } from 'viem';
import { depositUSDC } from '@svrn/sdk/bridge';

const wallet = createWalletClient({
  chain: svrnChain,
  transport: custom(window.ethereum),
});

const hash = await depositUSDC(wallet, {
  amount: 1000n * 10n ** 6n, // 1000 USDC
});
Read Contract State
import { getActiveCitizens } from '@svrn/sdk/ubc';
import { getVotePower } from '@svrn/sdk/governance';

const citizens = await getActiveCitizens(client);
const power = await getVotePower(client, {
  address: '0x...',
});

Modules

@svrn/sdk/bridge

One-way fiat-to-UCU bridge operations

depositUSDC()depositETH()getTotalDeposited()getDailyDeposited()
@svrn/sdk/ubc

Universal Basic Compute enrollment and claims

enrollCitizen()claimUBC()getActualUBCPerPeriod()getActiveCitizens()
@svrn/sdk/governance

Quadratic voting and conviction-weighted governance

createProposal()castVote()stakeForVoting()getVotePower()getEffectiveVotes()
@svrn/sdk/citizenship

Human and agent identity registration

registerHuman()registerAgent()isCitizen()getTotalCitizens()
@svrn/sdk/bonfire

Revenue overflow burn mechanics and epoch stats

getCurrentOverflow()getEpochStats()finalizeEpoch()getBonfireStats()

Chain Definition

svrnChain
export const svrnChain = {
  id: 741741,
  name: 'SVRN Chain',
  nativeCurrency: {
    name: 'Unified Compute Unit',
    symbol: 'UCU',
    decimals: 18,
  },
  rpcUrls: {
    default: {
      http: ['https://rpc.svrn.chain'],
      webSocket: ['wss://rpc.svrn.chain'],
    },
    public: {
      http: ['https://rpc.svrn.chain'],
      webSocket: ['wss://rpc.svrn.chain'],
    },
  },
  blockExplorers: {
    default: {
      name: 'SVRN Explorer',
      url: 'https://explorer.svrn.chain',
    },
  },
} as const;
Chain ID
741741
Native Currency
UCU
Decimals
18
Consensus
OP Stack L2