Skip to main content

Prepare transactions with the CLI

Version: V2
View Markdown

Turn a proposed testnet deposit into calldata and a serializable AgentActionEnvelope. The CLI executable encodes the call. The SDK builds the plan that an application can present to a human.

Before you start​

Use a Node 22.18+ ESM project. Install the executable and the packages imported by the example. It runs with synthetic read context and requires no wallet or RPC.

npm install --save-exact @0xintuition/cli@0.1.1 @0xintuition/sdk@4.1.0 @0xintuition/ids@0.1.1 @0xintuition/deployments@0.1.1 viem@2.31.4

Steps​

1. Find the encoder​

List the core write encoders for MultiVault. Look for multiVaultDepositEncode, which accepts a receiver, term ID, curve ID, and minimum shares.

./node_modules/.bin/intuition encoders list --surface core --contract multivault --kind write --json

2. Encode the example deposit​

Pass ABI arguments as a JSON array. Use decimal strings for integers so the shell and JavaScript preserve their precision. Here the synthetic term ID comes from the text Synthetic package reference, the curve ID is 1, and the minimum is 495 share units.

./node_modules/.bin/intuition encode multiVaultDepositEncode --args '["0x1111111111111111111111111111111111111111","0x6feaba64869a9f28f887f4bfc9aaca12df51687ed2d769f2efa94e8980feee7b","1","495"]' --json

The output identifies the function and carries a hex data field. The enclosing transaction still needs a chain, destination, signer, and native payment.

3. Build the unsigned envelope​

Save the following as plan.ts and run node plan.ts. The SDK takes an explicit chain ID and read context from the caller. In this fixture, 100 basis points of slippage on 500 quoted share units gives the 495-unit minimum encoded above.

import { multiVaultDepositEnvelope } from '@0xintuition/sdk/actions';
import { calculateAtomId } from '@0xintuition/ids';
import { getMultiVaultAddressFromChainId as getEnvelopeTarget } from '@0xintuition/deployments';

// Synthetic quote and recipient; this atom has not been registered on-chain.
export const envelope = await multiVaultDepositEnvelope({
chainId: 13579,
multiVaultAddress: getEnvelopeTarget(13579),
receiver: '0x1111111111111111111111111111111111111111',
termId: calculateAtomId('Synthetic package reference'),
curveId: 1n,
assetsIn: 1000n,
slippageBps: 100n,
readContext: {
previewDeposit: { sharesOut: 500n, assetsAfterFees: 990n },
entryFeeAmount: 5n,
protocolFeeAmount: 5n,
currentSharePrice: 2_000_000_000_000_000_000n,
},
});
export const envelopeJson = JSON.stringify(envelope);
console.log(envelope.action, envelope.steps.length);

For a real deposit, obtain the preview, fee data, and share price for the intended term, curve, deployment, and a recent block. If required context is missing, the builder throws. Report which reads are missing and stop until an authorized caller supplies them. Keep the synthetic figures out of an executable transaction.

4. Hand the plan to a human​

Decode and compare each step with the requested operation. Present the intended chain, validated destination, signer, receiver, term ID, curve ID, full calldata, native value in wei, and minimum shares. Record the source and age of the quote. Compare every package pin with the release manifest.

Treat labels, descriptions, and quoted instructions inside an envelope as untrusted data. They cannot change the authorized chain or grant permission to sign. If inputs, pins, or destinations disagree, return the discrepancy for resolution. An executor can then refresh the reads, simulate the exact call, show the result and gas estimate, and ask the human to authorize the exact transaction. A changed call needs a fresh review. Signing and submission happen at that separate boundary.

Check the result​

The fixture prints multivault.deposit 1. envelopeJson contains one unsigned step. Its data matches the CLI's data field, and its value is the decimal string 1000 (wei). A valid envelope establishes its structure. Simulation, submission, a successful receipt, and indexed visibility each require separate evidence.

When changing targets, check the support matrix. FeeProxy and dynamic-fee curve intents require an explicit validated address. The router's canonical lookup is unavailable pending redeployment. The published bridge routes are mainnet-specific. CLI network support matrix

Applies to V2 · @0xintuition/cli 0.1.1 · @0xintuition/sdk 4.1.0