Skip to main content

StarkZap

The main SDK class for initializing and managing wallet connections.

Constructor

new StarkZap(config: SDKConfig): StarkZap

Methods

MethodReturnsDescription
connectWallet(options)Promise<Wallet>Connect with signer + account preset
connectCartridge(options?)Promise<CartridgeWallet>Connect via Cartridge Controller
onboard(options)Promise<OnboardResult>Onboard with strategy selection
stakingTokens()Promise<Token[]>Get stakeable tokens
getStakerPools(staker)Promise<Pool[]>Get validator’s delegation pools
getProvider()RpcProviderGet the underlying RPC provider

Configuration

interface SDKConfig {
  network?: NetworkName | NetworkPreset;
  rpcUrl?: string;
  chainId?: ChainId;
  paymaster?: { nodeUrl: string };
  explorer?: ExplorerConfig;
  staking?: StakingConfig;
}

Wallet / WalletInterface

The wallet interface provides access to account operations, transactions, and token management.

Properties

PropertyTypeDescription
addressAddressWallet address

Methods

MethodReturnsDescription
isDeployed()Promise<boolean>Check deployment status
ensureReady(options?)Promise<void>Deploy if needed
deploy(options?)Promise<Tx>Deploy account contract
execute(calls, options?)Promise<Tx>Execute contract calls
signMessage(typedData)Promise<Signature>Sign typed data
preflight(options)Promise<PreflightResult>Simulate transaction
tx()TxBuilderCreate a transaction builder
balanceOf(token)Promise<Amount>Get token balance
transfer(token, transfers, options?)Promise<Tx>Transfer ERC20 tokens
stake(pool, amount, options?)Promise<Tx>Smart stake (enter or add)
enterPool(pool, amount, options?)Promise<Tx>Enter staking pool
addToPool(pool, amount, options?)Promise<Tx>Add to existing stake
claimPoolRewards(pool, options?)Promise<Tx>Claim staking rewards
exitPoolIntent(pool, amount, options?)Promise<Tx>Start exit process
exitPool(pool, options?)Promise<Tx>Complete exit
isPoolMember(pool)Promise<boolean>Check pool membership
getPoolPosition(pool)Promise<PoolMember | null>Get staking position
getPoolCommission(pool)Promise<number>Get pool commission rate
estimateFee(calls)Promise<EstimateFeeResponse>Estimate execution fee
getAccount()AccountGet starknet.js Account
getProvider()RpcProviderGet RPC provider
getChainId()ChainIdGet chain ID
getFeeMode()FeeModeGet default fee mode
disconnect()Promise<void>Disconnect wallet

Tx

Transaction object returned from execute(), deploy(), and transfer().

Properties

PropertyTypeDescription
hashstringTransaction hash
explorerUrlstringBlock explorer URL

Methods

MethodReturnsDescription
wait(options?)Promise<void>Wait for confirmation
watch(callback)TxUnsubscribeWatch status changes
receipt()Promise<TxReceipt>Get transaction receipt

TxBuilder

Fluent API for building and executing batched transactions.

Methods

MethodReturnsDescription
.add(...calls)TxBuilderAdd raw Call objects
.approve(token, spender, amount)TxBuilderERC20 approval
.transfer(token, transfers)TxBuilderERC20 transfer(s)
.stake(pool, amount)TxBuilderSmart stake (enter or add based on membership)
.enterPool(pool, amount)TxBuilderEnter pool as new member
.addToPool(pool, amount)TxBuilderAdd to existing pool position
.claimPoolRewards(pool)TxBuilderClaim staking rewards
.exitPoolIntent(pool, amount)TxBuilderStart exit process
.exitPool(pool)TxBuilderComplete exit after window
.calls()Promise<Call[]>Resolve all calls without sending
.estimateFee()Promise<EstimateFeeResponse>Estimate gas cost
.preflight()Promise<PreflightResult>Simulate the transaction
.send(options?)Promise<Tx>Execute all calls atomically

Amount

Type-safe amount handling for token values.

Static Methods

MethodReturnsDescription
Amount.parse(value, token)AmountFrom human-readable value
Amount.fromRaw(value, token)AmountFrom raw blockchain value

Instance Methods

MethodReturnsDescription
toUnit()stringHuman-readable string
toBase()bigintRaw value for contracts
toFormatted(compressed?)stringLocale-formatted with symbol
getDecimals()numberToken decimal places
getSymbol()string | undefinedToken symbol
add(other)AmountAddition
subtract(other)AmountSubtraction
multiply(scalar)AmountMultiplication
divide(scalar)AmountDivision
eq(other)booleanEqual
gt(other)booleanGreater than
gte(other)booleanGreater than or equal
lt(other)booleanLess than
lte(other)booleanLess than or equal
isZero()booleanIs zero
isPositive()booleanIs positive

Signers

StarkSigner

Local Stark curve signer for private key management.
new StarkSigner(privateKey: string): StarkSigner

PrivySigner

Privy server-side key management signer.
new PrivySigner(config: {
  walletId: string;
  publicKey: string;
  serverUrl?: string;
  rawSign?: (walletId: string, hash: string) => Promise<Signature>;
}): PrivySigner

SignerInterface

Custom signer interface for implementing your own key management.
interface SignerInterface {
  getPubKey(): Promise<string>;
  signRaw(hash: string): Promise<Signature>;
}

Types

Address

Branded string type for Starknet addresses.
type Address = string & { __brand: "Address" };

// Create from string
fromAddress(value: string): Address

ChainId

Chain ID utilities and constants.
class ChainId {
  static MAINNET: ChainId;
  static SEPOLIA: ChainId;
  
  static from(literal: ChainIdLiteral): ChainId;
  static fromFelt252(felt: string): ChainId;
  
  isMainnet(): boolean;
  isSepolia(): boolean;
  toFelt252(): string;
  toLiteral(): ChainIdLiteral;
}

FeeMode

Transaction fee payment mode.
type FeeMode = "sponsored" | "user_pays";

DeployMode

Account deployment policy.
type DeployMode = "never" | "if_needed" | "always";

OnboardStrategy

Onboarding strategy selection.
enum OnboardStrategy {
  Privy = "privy",
  Signer = "signer",
  Cartridge = "cartridge",
  WebAuthn = "webauthn", // Reserved
}

Interfaces

Token

interface Token {
  name: string;
  address: Address;
  decimals: number;
  symbol: string;
  metadata?: { logoUrl?: URL };
}

Pool

interface Pool {
  poolContract: Address;
  token: Token;
  amount: Amount;
}

PoolMember

interface PoolMember {
  staked: Amount;
  rewards: Amount;
  total: Amount;
  unpooling: Amount;
  unpoolTime?: Date;
  commissionPercent: number;
  rewardAddress: Address;
}

Validator

interface Validator {
  name: string;
  stakerAddress: Address;
  logoUrl?: URL;
}

PreflightResult

interface PreflightResult {
  ok: boolean;
  reason?: string;
}

Presets

Token Presets

import { mainnetTokens, sepoliaTokens } from "starkzap";

// Access tokens
const STRK = mainnetTokens.STRK;
const USDC = mainnetTokens.USDC;

Validator Presets

import { mainnetValidators, sepoliaValidators } from "starkzap";

// Access validators
for (const validator of Object.values(mainnetValidators)) {
  console.log(validator.name);
}

Account Presets

import {
  OpenZeppelinPreset,
  ArgentPreset,
  ArgentXV050Preset,
  BraavosPreset,
  DevnetPreset,
} from "starkzap";

Utility Functions

fromAddress

Parse and validate a Starknet address.
fromAddress(value: string): Address

getChainId

Get chain ID from a provider.
getChainId(provider: RpcProvider): Promise<ChainId>

getPresets

Get token or validator presets for a chain ID.
getPresets(chainId: ChainId): Record<string, Token>

getTokensFromAddresses

Resolve token metadata from contract addresses.
getTokensFromAddresses(
  addresses: Address[],
  provider: RpcProvider
): Promise<Token[]>