Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

simulate

Gas-simulate an unsigned transaction. Returns the simulated gas usage scaled by a default multiplier.

Signature

function simulate(
  client: Client,
  parameters: {
    simulate: SimulateRequest
    scale?: number
    height?: number
  },
): Promise<SimulateResponse>

Example

import { createPublicClient, createTransport, testnet } from "@left-curve/sdk"
import type { Address } from "@left-curve/sdk"
 
const client = createPublicClient({ chain: testnet, transport: createTransport() })
const sender: Address = "0x1234567890abcdef1234567890abcdef12345678"
 
const { gasLimit, gasUsed } = await client.simulate({
  simulate: {
    sender,
    msgs: [
      {
        transfer: {
          "0xabcdef1234567890abcdef1234567890abcdef12": { dango: "1000000" },
        },
      },
    ],
    data: null,
  },
})

Parameters

simulateSimulateRequest. The unsigned transaction shape: { sender, msgs, data }.

scalenumber, optional, default 1.3. Multiplier applied to gasUsed before returning.

heightnumber, optional. Block height to simulate at. Default 0 (latest).

Returns

SimulateResponse{ gasLimit, gasUsed }. gasUsed is Math.round(rawGasUsed * scale).

Notes

  • The 1.3× scaling factor is the default safety margin used by signAndBroadcastTx. Pass scale: 1 to see the unmodified estimate.
  • Simulation runs the messages against the latest state and may differ from the eventual on-chain result if the state changes between simulation and broadcast.

See also