Reference
SDK API Reference
@asentum/sdk · Estimated read time: 10 minutes
TL;DR
@asentum/sdk is the first-party TypeScript SDK — ~14 KB bundled, works in Node and the browser, zero Solidity, no ethers.js dependency. Three classes cover everything:
AsentumClient— read-only chain access.AsentumWallet— keypair, signing, submitting.AsentumContract— typed contract interactions.
Install
# or
pnpm add @asentum/sdk
Works from Node 18+ and all modern browsers. No polyfills needed for the browser bundle.
AsentumClient
Read-only interface to the chain. Wraps JSON-RPC with typed responses.
import { AsentumClient } from '@asentum/sdk';
const client = new AsentumClient('https://testnet.asentum.com');| Method | Returns |
|---|---|
| getChainInfo() | ChainInfo |
| getBlockNumber() | bigint |
| getBlock(n | hash) | Block |
| getBalance(addr) | bigint (wei) |
| getNonce(addr) | bigint |
| getCode(addr) | string | null |
| getContractSource(addr) | string | null |
| getReceipt(hash) | Receipt | null |
| getTransaction(hash) | Transaction | null |
| viewCall({ to, method, args }) | ViewCallResult |
| getValidators() | ValidatorInfo[] |
AsentumWallet
A Dilithium3 keypair bound to a client. Three ways to construct:
import { AsentumWallet } from '@asentum/sdk';
// 1. Brand-new random keypair
const w1 = AsentumWallet.create(client);
// 2. Deterministic from seed bytes
const w2 = AsentumWallet.fromSeed(client, seedBytes);
// 3. From an existing secret key
const w3 = AsentumWallet.fromSecretKey(client, skBytes);| Method | Purpose |
|---|---|
| address | Readonly EIP-55 address string. |
| getBalance() | Shortcut for client.getBalance(this.address). |
| sendTransfer({ to, amount }) | Build, sign, broadcast a transfer. Returns SentTx. |
| sendCall({ to, method, args, value? }) | Signed contract call. |
| deploy(source, initArgs?) | Deploy a contract from JS source. Returns AsentumContract. |
| requestFaucet() | Testnet convenience — asks the faucet for test ASE. |
Every send* method returns a SentTx with .hash and .wait() — finality is instant, so .wait() resolves in ~2 seconds with the receipt.
AsentumContract
A handle to a deployed contract. Obtain one by wallet.deploy() or by attaching to an address:
const contract = new AsentumContract(client, '0x...');
const withSigner = contract.connect(wallet);
const answer = await contract.view('getAnswer');
const full = await contract.viewFull('getDetails');
const tx = await withSigner.send('setAnswer', [42]);
await tx.wait();| Method | Purpose |
|---|---|
| address | The contract address. |
| view(method, args?) | Read-only call — free, no tx. |
| viewFull(method, args?) | Read-only call with gas + events metadata. |
| send(method, args?, opts?) | Write call — requires a connected wallet. |
| connect(wallet) | Returns a new instance bound to a signer. |
| getSource() | Fetch the deployed JavaScript source. |
| waitForDeploy() | Resolves when the deploy tx is final. |
See Writing Contracts for the contract side of this interface.
parseAse / formatAse
import { parseAse, formatAse } from '@asentum/sdk';
parseAse('1.5') // 1500000000000000000n (bigint wei)
formatAse(1000000000n) // '0.000000001' (string ASE)1 ASE = 1018 wei, same as Ether.
Types
All public types are exported for TypeScript consumers:
Balance,Block,BlockHeader,ChainInfo,MetadataReceipt,Transaction,TxResult,ValidatorInfo,ViewCallResultDeployOpts,SendCallOpts,SendTransferOpts,SentTx
Examples
Deploy, write, read:
import { AsentumClient, AsentumWallet } from '@asentum/sdk';
const client = new AsentumClient('https://testnet.asentum.com');
const wallet = AsentumWallet.create(client);
await wallet.requestFaucet();
const contract = await wallet.deploy(`
function init() { storage.set('n', 0n); }
function inc() { storage.set('n', storage.get('n') + 1n); emit('Inc', {}); }
function get() { return storage.get('n'); }
`);
await (await contract.send('init')).wait();
await (await contract.send('inc')).wait();
console.log(await contract.view('get')); // 1nRead next