Docs › SDK
Arfi SDK Beta
@arfi/sdk is a typed TypeScript client for Arfi Mainnet (chain 5452), built on ethers v6. It bundles the official contract addresses and ABIs, so you can read balances, quote swaps, check vesting and call the ArfiScan API in a few lines.
Install
The package is not on the npm registry yet. Install the tarball from this site (needs Node 18+ and ethers v6 as a peer dependency):
npm i ethers https://docs.arficoin.com/downloads/arfi-sdk-0.1.0-beta.1.tgz
Download: arfi-sdk-0.1.0-beta.1.tgz (8 KB, MIT). SHA-256:
78305b7e9e09fd4d2fa9315582e49b13b4936243db1a6ea944897854b9c15e15
Quick start
import { Arfi, parseArfi, formatArfi } from "@arfi/sdk";
const arfi = Arfi.mainnet();
console.log("block", await arfi.blockNumber());
console.log(formatArfi(await arfi.balance("0xYourAddress")), "ARFI");
// Quote 100 ARFI -> aUSD on ArfiSwap (0.3% fee included)
const q = await arfi.quote("ARFI", "aUSD", parseArfi("100"));
console.log(formatArfi(q.amountOut), "aUSD, price impact", q.priceImpactBps / 100, "%");
// Public data
console.log((await arfi.scan.price()).spotAusdPerArfi);
console.log((await arfi.supply()).circulatingSupply);
Sending transactions
Attach any ethers Signer. populate* methods return a plain transaction request, so they also work with wagmi, a hardware wallet or the MultiSig.
import { Wallet } from "ethers";
import { Arfi, parseArfi } from "@arfi/sdk";
const base = Arfi.mainnet();
const arfi = base.withSigner(new Wallet(process.env.PRIVATE_KEY, base.provider));
const me = await arfi.signer.getAddress();
await (await arfi.wrap(parseArfi("1"))).wait(); // ARFI -> WARFI, 1:1
await (await arfi.unwrap(parseArfi("1"))).wait(); // WARFI -> ARFI, 1:1
// Swap 1 ARFI for aUSD with 1% slippage
const q = await arfi.quote("ARFI", "aUSD", parseArfi("1"));
const tx = arfi.populateSwapExactArfiForTokens({
tokenOut: "aUSD", amountIn: parseArfi("1"),
minAmountOut: (q.amountOut * 99n) / 100n, to: me,
});
await (await arfi.signer.sendTransaction(tx)).wait();
API reference
| Method | What it does |
|---|---|
Arfi.mainnet(opts?) | Create a client. Options: rpcUrl, provider, signer, addresses. |
withSigner(signer) | Same client with a signer attached for writes. |
blockNumber() gasPrice() balance(addr) | Chain height, gas price, native ARFI balance (wei). |
token(addr) tokenBalance(token, owner) | ARFI-20 name, symbol, decimals, supply; balances. |
wrap(wei) unwrap(wei) | Native ARFI to WARFI and back, 1:1. populateWrap / populateUnwrap return the request only. |
reserves(a, b) quote(in, out, amount) | Pool reserves and a constant-product quote with price impact. Tokens: address, "ARFI" or "aUSD". Single hop only. |
populateSwapExactArfiForTokens() populateSwapExactTokensForTokens() approveRouter() | Swap transaction builders and router approval. |
vesting(addr) claimVesting() | ArfiVestingV2 schedule, vested and claimable amounts (paid in native ARFI); claim as the beneficiary. |
farm(account?) | ArfiFarm totals, reward rate, period end and per-account staked / earned. |
supply() | Official supply.json: total, circulating, locked and definitions. |
scan.* | Typed wrapper over the ArfiScan REST API: price, priceHistory, stats, supply, validators, blocks, txs, address, tokens, accounts, search, plus get(path) for anything else. |
Amounts are bigint in wei (18 decimals). Helpers: parseArfi("1.5"), formatArfi(wei). Official addresses are exported as MAINNET_ADDRESSES and listed on Contracts.
Without the SDK
Arfi is a standard EVM chain. Plain ethers, viem or web3.py work with the network parameters (chain ID 5452, RPC https://rpc.arficoin.com). The SDK only saves you the addresses, ABIs and boilerplate.
Status and roadmap
- 0.1 (now): mainnet reads, swap quotes, transaction builders, vesting, farm, ScanApi. Live-tested against mainnet.
- Next: publish to the npm registry, add a viem adapter, event helpers, and ArfiSwap liquidity helpers.
- Bugs and requests: [email protected] or the Telegram group. Security issues: see Security.
- Building something with it? Builder grants are open.