tmpnetjs SDK
The consumer SDK for scripting scenarios against a running Interchain Kit network
tmpnetjs is the JavaScript analog of AvalancheGo's tmpnet. The producer side boots the network (driven by pnpm run up); the consumer side is the SDK you import in your scripts. It reads the artifacts written to .interchain-kit/ and hands you ready-to-use viem clients.
The demo scripts (ICM Messaging, Token Transfer, Validator Management) are all thin consumers of this SDK.
Consumer API
| Export | Purpose |
|---|---|
loadNetwork() | Load the running network's topology from network.json (chains, blockchain IDs, Teleporter/registry addresses, funded key). Walks up from the current directory to find .interchain-kit/artifacts/network.json. |
pickL1(network, name?) | Select an L1 from the network by name (defaults to the first L1). |
makeClients(chain, privateKey) | Build a viem publicClient + walletClient (plus account and chain) for a given chain. |
loadArtifact(name) | Load a compiled contract's abi and bytecode by name (e.g. "SimpleSender") from contracts/out/. |
blockchainIdToBytes32(id) | Convert a blockchain ID into the bytes32 form Teleporter uses to address destinations. |
pollUntil(fn, predicate, opts) | Poll an async read until predicate is satisfied or timeoutMs elapses — used to wait for cross-chain delivery. |
Run from inside the repo
loadNetwork() and loadArtifact() walk up the directory tree from process.cwd() to locate .interchain-kit/ and contracts/out/. Running scripts from the repo root is the reliable choice; running from a directory outside the repo throws network.json not found.
Use tmpnetjs in Your Own Script
Point a script at the running network in a few lines:
import { loadNetwork, makeClients, pickL1, pollUntil } from "tmpnetjs";
const net = loadNetwork();
const dst = pickL1(net, "myl1");
const { publicClient, walletClient } = makeClients(net.cChain, net.funded.privateKey);
// … your ICM/ICTT/whatever scenarioProducer API
The producer side — up, down, Network.start, captureSnapshot, and friends — is also exported for programmatic orchestration. Most workflows drive it through pnpm run up / pnpm run down instead; see packages/tmpnetjs/README.md in the repo for the full surface.
Next Steps
Is this guide helpful?