Skip to main content

SDK & Code Examples

Use any EVM library. Below are copy-paste starters; the runnable examples repo contains full clone-and-run projects.

Chain config

Network Name
Super AI Chain Testnet
Chain ID
8848 (0x2290)
Currency Symbol
SUP
RPC URL
https://rpc-testnet.superaichain.ai
WebSocket
wss://wss-testnet.superaichain.ai
Block Explorer
https://scan-testnet.superaichain.ai

ethers v6

import { JsonRpcProvider, Wallet, parseEther } from 'ethers';

const provider = new JsonRpcProvider('https://rpc-testnet.superaichain.ai', 8848);
const wallet = new Wallet(process.env.PRIVATE_KEY!, provider);

const tx = await wallet.sendTransaction({ to: wallet.address, value: parseEther('0.01') });
console.log((await tx.wait())?.hash);

viem

import { createPublicClient, http, defineChain } from 'viem';

export const superTestnet = defineChain({
id: 8848,
name: 'Super AI Chain Testnet',
nativeCurrency: { name: 'Super AI Coin', symbol: 'SUP', decimals: 18 },
rpcUrls: { default: { http: ['https://rpc-testnet.superaichain.ai'] } },
});

const client = createPublicClient({ chain: superTestnet, transport: http() });
console.log(await client.getBlockNumber());

wagmi (React)

import { createConfig, http } from 'wagmi';
import { superTestnet } from './chains';

export const config = createConfig({
chains: [superTestnet],
transports: { [superTestnet.id]: http('https://rpc-testnet.superaichain.ai') },
});

@superaichain/sdk

A typed helper that pre-bundles chain config, contract addresses, and ABIs:

import { SuperClient } from '@superaichain/sdk';
import { parseUnits } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const client = SuperClient.testnet({ account });
const { stables } = client.addresses;

// Best-route quote across V2 + V3 (single or two-hop via WSUP).
const route = await client.swap.routeExactIn({
tokenIn: stables.WSUP,
tokenOut: stables.tUSDT,
amountIn: parseUnits('1', 18),
});

// Swap via the Universal Router + Permit2 (approve + sign handled once).
const { hash } = await client.swap.exactInUniversal({
tokenIn: stables.WSUP,
tokenOut: stables.tUSDT,
amountIn: parseUnits('1', 18),
});

See DEX for the full Universal Router + Permit2 walkthrough (TS + Python).

note

@superaichain/sdk and the runnable examples repo are tracked in the dev-plan (sections 52 / 54). Addresses below come from the live deployment:

ContractAddressExplorer
v2Factory0xbc2FDEd5A1eb9570DC07Bd612c6A2a11aD5584BEview ↗
v2Router020x97E36Bb18B91063f3Db6F9D68E12712792a91cc3view ↗
v3Factory0x72A19e1D0E9412a93FEddA95d97Ab7dfa2ae92e3view ↗
v3PositionManager0x8D1A0Cc629bF35220D12B65abf7DCA1f172D611eview ↗
v3Router0x88554F2c4Aa6AC5cBd361268742EF77a4b1c1e58view ↗
v3Quoter0x44522A5eda8500d3A80BC97c5480E0279A25bf3eview ↗
universalRouter0xAbe4C84F49378A1f9f6f156C0f9457Be867c7F1Eview ↗
permit20xF9633dB82BE2bbb028D7EB647e1AfB4EaF9c60fDview ↗

Runnable examples

Full clone-and-run projects live in the superaichain/examples repo (MIT). 29 examples across 5 stacks — each with a ≤100-line README and 跑起来 in ≤3 commands.

git clone https://github.com/superaichain/examples
cd examples/hardhat/erc20-deploy
pnpm install && cp .env.example .env && pnpm run deploy
StackExamples
Hardhaterc20-deploy · erc721-mint · upgrade-uups · multisig-safe-deploy · verify-on-blockscout
Foundryerc20-deploy · invariant-test · fuzz-test · deploy-script-multichain · verify-on-blockscout
viemread-balance · send-tx · bridge-deposit · swap-exactin · ens-resolve
ethers v6read-balance · send-tx · bridge-deposit-abi
web3.pyread-balance · send-tx · faucet-claim-oauth
GraphQLbridge-history · dex-tvl · ens-reverse-lookup
dAppsnextjs-wallet-connect · vite-react-swap · faucet-bot-discord
CI templatesfoundry · hardhat

Next steps