Mandatedocs
ReferenceSDK

Errors, addresses and chains

Decoding contract reverts, and the constants the SDK ships.

Errors

import { describeError, decodeMandateError, MandateError } from "@yashjain99/mandate-sdk";

try { await client.execute(plan, 2); }
catch (e) { console.log(describeError(e)); }   // "PerTxCapExceeded(5000000000, 100000000)"
FunctionReturns
decodeMandateError(e)MandateError | null; code is the contract's custom error name, details.args the decoded arguments
extractRevertData(e)the 0x… revert data buried in a viem error chain
describeError(e)decoded custom error, else viem's short message, else String(e)
decodeRevertData(hex), describeInnerRevert(hex)decode raw revert data; CallFailed is expanded to the inner call's reason, e.g. CallFailed(call 1: ERC20InsufficientBalance(0x…, 2000000, 73007631))

client.execute already applies this; StepResult.error is human-readable. The custom errors are listed in Contracts.

Addresses

import { BASE_SEPOLIA, ARC_TESTNET, ARB_SEPOLIA, CCTP, DOMAINS, usdcFor, loadDeployment } from "@yashjain99/mandate-sdk";
ExportContents
BASE_SEPOLIAchainId 84532, usdc, weth, comet, domain 6
ARC_TESTNETchainId 5042002, usdc (ERC-20 view), domain 26
ARB_SEPOLIAchainId 421614, usdc, weth, aavePool, domain 3
CCTPtokenMessengerV2, messageTransmitterV2, irisSandbox, fastFinality 1000, standardFinality 2000
DOMAINSethereumSepolia 0, arbitrumSepolia 3, baseSepolia 6, arcTestnet 26
usdcFor(chainId)the USDC ERC-20 address for a supported chain
loadDeployment(name)reads contracts/deployments/<name>.json (MANDATE_DEPLOYMENTS_DIR overrides the directory)

Values are listed in Chains and addresses.

Chains

import { chains, arcTestnet, explorerTx } from "@yashjain99/mandate-sdk/chains";

chains.baseSepolia, chains.arcTestnet, chains.arbitrumSepolia are viem Chain objects whose default RPC honours BASE_SEPOLIA_RPC, ARC_TESTNET_RPC and ARB_SEPOLIA_RPC. explorerTx(chain, hash) builds an explorer URL. This subpath is browser-safe.

ABIs

import { MandateAccountAbi, MandateFactoryAbi, erc20Abi, wethAbi, cometAbi, tokenMessengerV2Abi, messageTransmitterV2Abi } from "@yashjain99/mandate-sdk/abi";

Generated from the Foundry build by packages/core/scripts/gen-abi.ts. Browser-safe.

Approval message helpers

approvalText(fields), formatUsdc6(bigint), callsHash(calls), planIdToBytes32(id) and verifyGuardianSignature(guardian, text, signature) implement the spec byte for byte.

On this page