Skip to Content
Reference@aeva/sdk

@aeva/sdk

@aeva/sdk is not published to a package registry yet. This page documents the version the explorer, the app and the faucet use (0.10.0); it will say where to install it from once it is published.

A TypeScript SDK with five exports: api, evm, policy, tx and units. Arithmetic is BigInt-only; amounts are strings and never become JavaScript numbers.

import { api, evm, policy, tx, units } from "@aeva/sdk";

api — the indexer client

Types are generated from the indexer’s OpenAPI description (the routes on Indexer API). createClient(baseUrl) is a typed fetch wrapper:

const client = api.createClient("https://indexer.aevachain.com"); const status = await client.get("/v1/status"); const holders = await client.get("/v1/assets/{id}/kinds/{kind}/holders", { path: { id, kind: 1 }, query: { limit: 50 }, });

Errors are api.ApiError { status, code, message }.

policy — the policy grammar

policy.Policy is the JSON shape of a policy (open | all | any | credential | allowlist | max_holders). policy.describePolicy(p) renders it as sentences; policy.rulePath(p, [1]) renders the chain’s denial path, for example all[1].credential(investor.accredited).

units — exact amounts

units.formatUnits("1500000", 6); // "1.5" units.parseUnits("1.5", 6); // 1500000n units.wholeUnits(positions, kinds); // minimum over the bundled kinds units.percent(part, whole); // two exact decimals

evm — the AE-20 facade

evm.rightAddress(assetId, kindId); evm.bundleAddress(assetId); const right = evm.connectRight(assetId, 1, provider); // an ethers contract await evm.readPosition(right, holder); // { transferable, units, encumbered, wholeUnits } evm.chainParams(); // { chainId: 2382n, symbol: "AEVA", decimals: 18, … }

tx — native transactions

Message builders for what a holder sends — transfer, propose / accept / cancel, pledge / release / exercise, delegate / revokeDelegation / returnDelegation, claim / claimAll, redeemForPool — plus fee helpers (25·10⁹ aaeva per gas), simulate and signAndBroadcast over plain HTTP, for secp256k1 and eth_secp256k1 accounts alike. Direct signing only; Amino (and so Ledger) is not supported.

const msgs = [tx.transfer({ from, to, assetId, legs: [{ kindId: 0, units: "100" }] })]; const ep = { rpc, rest, chainId: "aeva-testnet-1" }; const sim = await tx.simulate(ep, { address, algo, pubkey }, msgs); // { ok, gasUsed } or { ok: false, error: "policy denied at …" } const fee = tx.fee(tx.withMargin(sim.gasUsed)); const res = await tx.signAndBroadcast(ep, signer, address, msgs, fee); // { hash, code, rawLog, height }
Last updated