SDK & Code Examples
Use any EVM library. Below are copy-paste starters; the runnable examples repo contains full clone-and-run projects.
Chain config
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:
| Contract | Address | Explorer |
|---|---|---|
| v2Factory | 0xbc2FDEd5A1eb9570DC07Bd612c6A2a11aD5584BE | view ↗ |
| v2Router02 | 0x97E36Bb18B91063f3Db6F9D68E12712792a91cc3 | view ↗ |
| v3Factory | 0x72A19e1D0E9412a93FEddA95d97Ab7dfa2ae92e3 | view ↗ |
| v3PositionManager | 0x8D1A0Cc629bF35220D12B65abf7DCA1f172D611e | view ↗ |
| v3Router | 0x88554F2c4Aa6AC5cBd361268742EF77a4b1c1e58 | view ↗ |
| v3Quoter | 0x44522A5eda8500d3A80BC97c5480E0279A25bf3e | view ↗ |
| universalRouter | 0xAbe4C84F49378A1f9f6f156C0f9457Be867c7F1E | view ↗ |
| permit2 | 0xF9633dB82BE2bbb028D7EB647e1AfB4EaF9c60fD | view ↗ |
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
| Stack | Examples |
|---|---|
| Hardhat | erc20-deploy · erc721-mint · upgrade-uups · multisig-safe-deploy · verify-on-blockscout |
| Foundry | erc20-deploy · invariant-test · fuzz-test · deploy-script-multichain · verify-on-blockscout |
| viem | read-balance · send-tx · bridge-deposit · swap-exactin · ens-resolve |
| ethers v6 | read-balance · send-tx · bridge-deposit-abi |
| web3.py | read-balance · send-tx · faucet-claim-oauth |
| GraphQL | bridge-history · dex-tvl · ens-reverse-lookup |
| dApps | nextjs-wallet-connect · vite-react-swap · faucet-bot-discord |
| CI templates | foundry · hardhat |