Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Setup

The SDK works the same way on every chain. You install it, pick the chain config, and create a client. Everything after that (wallets, sessions, execution) is the same code.

Install

npm install @altananetwork/sdk viem

Choose a chain

import { createClient, BNB, signerFromPrivateKey } from "@altananetwork/sdk";
 
const client = createClient({ chains: [BNB] }); // or ETHEREUM, CELO, BNB_TESTNET, CELO_SEPOLIA, BASE_SEPOLIA
const signer = signerFromPrivateKey(process.env.PRIVATE_KEY as `0x${string}`);
 
const wallet = await client.createWallet({ signer });
console.log(wallet.address);
ConfigChainChain idFund wallet.address with
BNBBNB Smart Chain (default)56BNB
ETHEREUMEthereum1ETH
CELOCelo42220CELO
BNB_TESTNETBNB Smart Chain Testnet97test BNB: faucet
CELO_SEPOLIACelo Sepolia11142220test CELO: faucet
BASE_SEPOLIABase Sepolia84532Base Sepolia ETH. Keystore writes on Sepolia are paid from this balance; ETH on Sepolia is not used

BNB Smart Chain, Ethereum and Celo are standalone: the Keystore is on the chain itself. Base Sepolia is an L2: the Keystore is on Sepolia and a KeyStoreCache on the L2 mirrors it. The SDK handles the L1 write and the proof into the cache inside grantSession and revokeSession. The L1 write is paid from the wallet's balance on the L2: the relay takes the registration fee and its own fee there and funds the write on the L1. BASE is also exported, for the L2 Keystore cache used by ensureKeyCached.

Multiple chains

createClient accepts several chains. A wallet has the same address on all of them. Calls pick one with chainId and use the default chain without it. A session is granted on one chain, or on several with chainIds, and revoked wherever it lives:

import { createClient, NETWORKS } from "@altananetwork/sdk";
 
const client = createClient({ chains: [...NETWORKS.mainnet], defaultChainId: 56 });
 
await client.execute({ /* ... */, chainId: 42220 });      // one chain: Celo
await client.grantSession({ /* ... */ });                  // the default chain: BNB
await client.grantSession({ /* ... */, chainId: 42220 });  // one chain: Celo
await client.grantSession({ /* ... */, chainIds: [56, 42220] });  // several in one call
await client.revokeSession({ wallet, signer, session });   // wherever the key lives

A wallet that is new on BNB Chain or Celo is registered as an agent (ERC-8004) after its first action, in a transaction of its own. agentIdentity sets the name and image it is listed with, and agentIdentity: false turns it off. See ERC-8004: agent identity.

NETWORKS.mainnet is BNB, Ethereum and Celo; NETWORKS.testnet is BNB testnet, Celo Sepolia and Base Sepolia. networkByChainId(id) returns the config for any chain the SDK knows, Sepolia included.

What's next