@bankofai/agent-wallet
v1.0.0-beta
Published
- **BaseProvider**: Abstract base class with a unified interface: - `getAccountInfo(): Promise<AccountInfo>` — returns `{ address: string }` (wallet address) - `signTx(unsignedTx: unknown): Promise<SignedTxResult>` — accepts an unsigned payload, signs
Downloads
60
Readme
Agent Wallet SDK (TypeScript)
Provider abstraction
- BaseProvider: Abstract base class with a unified interface:
getAccountInfo(): Promise<AccountInfo>— returns{ address: string }(wallet address)signTx(unsignedTx: unknown): Promise<SignedTxResult>— accepts an unsigned payload, signs it, and returns{ signedTx, signature? }
- Providers depend on an abstract KeystoreBase type, so you can inject other keystore implementations if needed (default is the file-based
Keystoreat~/.agent_wallet/Keystore). - TronProvider: Extends BaseProvider; uses TronWeb with local private-key signing.
- FlashProvider: Extends TronProvider; supports Privy remote signing and Flash node.
Keystore initialization is done via CLI
Create the keystore file and write credentials using the keystore CLI (recommended):
npx -p @bankofai/agent-wallet agent-wallet-keystore init
npx -p @bankofai/agent-wallet agent-wallet-keystore write privateKey "hex..."Provider usage
import { TronProvider } from '@bankofai/agent-wallet';
// Keystore file initialization is done via CLI.
// Providers read keystore data in the constructor.
const tron = new TronProvider({
// Optional overrides. Recommended: write these into keystore via CLI.
// privateKey: 'hex...',
});
const info = await tron.getAccountInfo(); // { address: 'T...' }
const signed = await tron.signTx(unsignedTx);Sign an arbitrary message
const sig = await tron.signMessage(Buffer.from('hello', 'utf8'));
console.log(sig);Keystore
A fixed-path Protobuf file stores account info (privateKey, apiKey, secretKey, etc.). The storage format is cross-language compatible with the Python SDK.
- Path: Default
~/.agent_wallet/Keystore; override viaKEYSTORE_PATHenv var or thefilePathoption. - Storage format: Protobuf wire format (
map<string, string>), NOT JSON. - Atomic writes: All writes go through a
.tmpfile thenrename, preventing data loss on crash. - Backward compatible: Can still read legacy plain-JSON keystore files.
Tests
npm testLogging
Set LOG_LEVEL to control verbosity: trace|debug|info|warn|error|fatal|silent.
