For AI agents: read the documentation index. Documentation pages are available as Markdown by appending .md to their URL, or requesting Accept: text/markdown.

Namera Docs

Simulate

Simulate calls and evaluate the selected session key’s API policies.

namera.executions.simulate(request) does not sign, submit, or sponsor an operation.

Usage

Install @namera-ai/sdk and viem. Replace the example IDs and recipient with your own. The selected session must permit these calls on Base Sepolia.

index.ts
import { namera } from "./client";
import type { SimulateExecutionRequest } from "@namera-ai/sdk";
import { parseEther } from "viem";

const request = {
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"),
      data: "0x",
    },
  ],
} satisfies SimulateExecutionRequest;

const simulation = await namera.executions.simulate(request);
if (!simulation.success) throw new Error(simulation.error.message);

console.log(simulation.data);

Returns

API methods return a Promise<NameraResult<T, E>>. When success is true, data contains the value described below and error is null. On failure, data is null and error describes the failure.

The JSON example shows the complete successful data, with illustrative values. Date-time values use ISO strings in JSON; bigint values use decimal strings. See Handling Results and Errors for the error shape.

  • namespace ("eip155"): Chain namespace.
  • walletId (string): Account UUID.
  • chainId (SupportedEvmChainId): Simulation network.
  • account (`0x${string}`): Smart-account address.
  • callsSucceeded (boolean): Whether the simulated calls succeeded.
  • simulation (EvmIntentSimulation): userOperation gas estimates and calls results, assetChanges, and transfers.
  • allowed (boolean): Point-in-time policy decision; not a guarantee of later execution.
  • sessionKeyId (string): Present when allowed is true.
  • denials (readonly { sessionKeyId: string; policyId: string; code: EvmPolicyDenialCode }[]): Nonempty when allowed is false; absent when allowed is true.

Example Response

{
  "namespace": "eip155",
  "walletId": "0199dfe1-0000-7000-8000-000000000001",
  "chainId": "eip155:84532",
  "account": "0x1111111111111111111111111111111111111111",
  "callsSucceeded": true,
  "simulation": {
    "userOperation": {
      "source": "eth_estimateUserOperationGas",
      "callGasLimit": "50000",
      "verificationGasLimit": "100000",
      "preVerificationGas": "50000",
      "maxFeePerGas": "1000000000",
      "maxPriorityFeePerGas": "1000000"
    },
    "calls": {
      "source": "viem.simulateCalls",
      "results": [
        {
          "status": "success",
          "returnData": "0x",
          "gasUsed": "21000"
        }
      ],
      "assetChanges": [],
      "transfers": [
        {
          "callIndex": 0,
          "from": "0x1111111111111111111111111111111111111111",
          "to": "0x2222222222222222222222222222222222222222",
          "value": "1000000000000000"
        }
      ]
    }
  },
  "allowed": true,
  "sessionKeyId": "0199dfe1-0000-7000-8000-000000000002"
}

Parameters

Pass a SimulateExecutionRequest object. Simulation does not accept a sponsor field.

namespace

  • Type: "eip155"
  • Required

The blockchain namespace. Use "eip155" for every currently supported Namera network. This is not a chain ID; select the specific network with chainId.

index.ts
import { namera } from "./client";
import type { SimulateExecutionRequest } from "@namera-ai/sdk";
import { parseEther } from "viem";

const request = {
  namespace: "eip155", 
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"),
      data: "0x",
    },
  ],
} satisfies SimulateExecutionRequest;

const simulation = await namera.executions.simulate(request);
if (!simulation.success) throw new Error(simulation.error.message);

console.log(simulation.data);

walletId

  • Type: string
  • Required

The account UUID returned by wallets.list() or wallets.get(). Pass its id, not its onchain address. The account must be accessible to the client’s credential.

index.ts
import { namera } from "./client";
import type { SimulateExecutionRequest } from "@namera-ai/sdk";
import { parseEther } from "viem";

const request = {
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001", 
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"),
      data: "0x",
    },
  ],
} satisfies SimulateExecutionRequest;

const simulation = await namera.executions.simulate(request);
if (!simulation.success) throw new Error(simulation.error.message);

console.log(simulation.data);

sessionKeyId

  • Type: string
  • Required

The session-key UUID returned by sessionKeys.list() or sessionKeys.get(). This identifies the delegated session, not its signing key or network installation. Your credential must have an active grant for this key.

For execution or signing, choose a key belonging to walletId with a confirmed installation on chainId and permissions that allow the requested operation.

index.ts
import { namera } from "./client";
import type { SimulateExecutionRequest } from "@namera-ai/sdk";
import { parseEther } from "viem";

const request = {
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002", 
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"),
      data: "0x",
    },
  ],
} satisfies SimulateExecutionRequest;

const simulation = await namera.executions.simulate(request);
if (!simulation.success) throw new Error(simulation.error.message);

console.log(simulation.data);

chainId

  • Type: SupportedEvmChainId
  • Required

The target network in CAIP-2 format. For Base Sepolia, use "eip155:84532", not 84532 or "84532". Use the network on which the account will execute, sign, or verify the payload.

The SDK restricts this field to the supported network IDs. Network availability is also checked by the API.

index.ts
import { namera } from "./client";
import type { SimulateExecutionRequest } from "@namera-ai/sdk";
import { parseEther } from "viem";

const request = {
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532", 
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"),
      data: "0x",
    },
  ],
} satisfies SimulateExecutionRequest;

const simulation = await namera.executions.simulate(request);
if (!simulation.success) throw new Error(simulation.error.message);

console.log(simulation.data);

calls

  • Type: readonly { to: EthereumAddress; value: bigint; data: Hex }[]
  • Required

One or more EVM calls, in execution order. Every call uses the same account, network, and session key. Supply all three fields on each call; there are no implicit values for value or data.

index.ts
import { namera } from "./client";
import { parseEther } from "viem";

const execution = await namera.executions.simulate({
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"), 
      data: "0x",
    },
  ],
});

if (!execution.success) throw new Error(execution.error.message);

console.log(execution.data);

calls.to

  • Type: EthereumAddress (`0x${string}`)
  • Required

The 20-byte recipient or contract address. Native transfers target the recipient; contract calls target the contract, not the recipient encoded in its arguments. The session’s permissions must allow this target.

index.ts
import { namera } from "./client";
import { parseEther } from "viem";

const execution = await namera.executions.simulate({
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222", 
      value: parseEther("0.001"),
      data: "0x",
    },
  ],
});

if (!execution.success) throw new Error(execution.error.message);

console.log(execution.data);

calls.value

  • Type: bigint
  • Required

The native-token amount in wei. Use parseEther("0.001") for 0.001 ETH or 0n for a call that sends no native tokens. Negative amounts are rejected. ERC-20 amounts belong in encoded calldata, not this field.

index.ts
import { namera } from "./client";
import { parseEther } from "viem";

const execution = await namera.executions.simulate({
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x2222222222222222222222222222222222222222",
      value: parseEther("0.001"), 
      data: "0x",
    },
  ],
});

if (!execution.success) throw new Error(execution.error.message);

console.log(execution.data);

calls.data

  • Type: Hex (`0x${string}`)
  • Required

The encoded contract call. Use "0x" for a native transfer. For contract functions, use viem’s encodeFunctionData; the SDK does not accept abi, functionName, or args directly in a call.

index.ts
import { namera } from "./client";
import { encodeFunctionData, erc20Abi, parseUnits } from "viem";

const result = await namera.executions.simulate({
  namespace: "eip155",
  walletId: "0199dfe1-0000-7000-8000-000000000001",
  sessionKeyId: "0199dfe1-0000-7000-8000-000000000002",
  chainId: "eip155:84532",
  calls: [
    {
      to: "0x3333333333333333333333333333333333333333",
      value: 0n,
      data: encodeFunctionData({
        abi: erc20Abi,
        functionName: "transfer",
        args: ["0x2222222222222222222222222222222222222222", parseUnits("1", 6)],
      }),
    },
  ],
});
if (!result.success) throw new Error(result.error.message);

console.log(result.data);

This encodes a transfer of one token with six decimals. Use your token’s actual decimals and pass its contract address as to.

Errors

Execution, authorization, and network failures return success: false. See Handling Results and Errors for authentication, transport, and contract errors.

Guide: Simulate Transactions.