Skip to main content

Overview

The StarkZap accepts configuration through a single options object. You can use network presets for simplicity, or provide explicit RPC URLs and chain IDs for custom setups.
New to blockchain? An RPC (Remote Procedure Call) is like an API endpoint for the blockchain—it’s how your app communicates with the network. A network is like an environment (production, staging, development). See the Glossary for more web2-friendly explanations.
The simplest way to configure the SDK is using network presets. Think of networks like environments:
  • mainnet = Production (real money, real transactions)
  • sepolia = Staging/Testnet (fake money for testing)
  • devnet = Local development (your own test blockchain)
import { StarkZap } from "starkzap";

// Mainnet
const sdk = new StarkZap({ network: "mainnet" });

// Sepolia testnet
const sdk = new StarkZap({ network: "sepolia" });

// Local devnet (starknet-devnet-rs)
const sdk = new StarkZap({ network: "devnet" });

Available Presets

PresetChain IDRPCExplorer
mainnetSN_MAINhttps://api.cartridge.gg/x/starknet/mainnethttps://voyager.online
sepoliaSN_SEPOLIAhttps://api.cartridge.gg/x/starknet/sepoliahttps://sepolia.voyager.online
devnetSN_SEPOLIAhttp://localhost:5050

Using Network Objects

You can also pass a custom NetworkPreset object:
import { StarkZap, networks } from "starkzap";

const sdk = new StarkZap({ network: networks.mainnet });
If you run your own blockchain node or use a different RPC provider (like using a different API endpoint):
An RPC provider is like choosing which API server to use. Just like you might use AWS, Google Cloud, or your own servers, you can use different RPC providers to connect to the blockchain.
import { StarkZap, ChainId } from "starkzap";

const sdk = new StarkZap({
  rpcUrl: "https://starknet-mainnet.infura.io/v3/YOUR_KEY",
  chainId: ChainId.MAINNET,
});
rpcUrl and chainId override values from network if both are provided.
Enable staking functionality to let users earn passive income by staking their tokens. When configured, users can:
  • 💰 Stake tokens in validator pools and earn rewards over time (like earning interest on a savings account)
  • 📈 Grow their holdings as rewards accumulate automatically
  • 🔄 Manage their positions by adding more tokens, claiming rewards, or exiting pools
  • 🏦 Support network security while earning passive income
Staking works out of the box using chain-aware staking contract presets:
import { StarkZap } from "starkzap";

const sdk = new StarkZap({
  network: "mainnet",
});
If needed, you can override the default preset:
import { StarkZap, fromAddress } from "starkzap";

const sdk = new StarkZap({
  network: "mainnet",
  staking: {
    contract: fromAddress(
      "0x00ca1702e64c81d9a07b86bd2c540188d92a2c73cf5cc0e508d949015e7e84a7"
    ),
  },
});
Ready to implement staking? See the Staking & Delegation Guide for complete instructions on how users can stake tokens, claim rewards, and manage their positions.

Complete Configuration Example

Here’s an example with all optional features configured:

Using Network Preset

import { StarkZap, fromAddress } from "starkzap";

const sdk = new StarkZap({
  // Network configuration
  network: "mainnet",
  
  // Optional: override staking contract preset
  staking: {
    contract: fromAddress(
      "0x00ca1702e64c81d9a07b86bd2c540188d92a2c73cf5cc0e508d949015e7e84a7"
    ),
  },
});

Using Custom RPC

import { StarkZap, ChainId, fromAddress } from "starkzap";

const sdk = new StarkZap({
  // Custom RPC configuration
  rpcUrl: "https://starknet-mainnet.infura.io/v3/YOUR_KEY",
  chainId: ChainId.MAINNET,
  
  // Optional: override staking contract preset
  staking: {
    contract: fromAddress(
      "0x00ca1702e64c81d9a07b86bd2c540188d92a2c73cf5cc0e508d949015e7e84a7"
    ),
  },
});
For paymaster configuration, see the Paymasters Guide for detailed setup instructions for AVNU Paymaster or Cartridge’s built-in paymaster.

Configuration Type Reference

interface SDKConfig {
  // Network (choose one)
  network?: NetworkName | NetworkPreset;
  rpcUrl?: string;
  chainId?: ChainId;
  
  // Optional features
  paymaster?: { nodeUrl: string; apiKey?: string };
  staking?: StakingConfig;
}

interface StakingConfig {
  contract: Address; // optional override
}
For paymaster configuration details, see the Paymasters Guide.

Next Steps