Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
联系支持
了解如何使用 Tenderly SDK 的 Simulator 类从代码中模拟交易:通过 simulateTransaction 方法运行单笔交易模拟,或使用 simulateBundle 在同一区块内模拟捆绑交易,并读取执行状态与模拟结果,加速智能合约的开发与调试流程。
Simulator
tenderly
simulator
simulateTransaction
const transaction = await tenderly.simulator.simulateTransaction({ transaction: { from: callerAddress, to: counterContract, gas: 20000000, gas_price: '19419609232', value: 0, input: counterContractAbiInterface.encodeFunctionData('inc', []), }, blockNumber: 3237677, });
simulateBundle
const simulations = await tenderly.simulator.simulateBundle({ transactions: [ { from: fromWalletAddress, to: myTokenAddress, gas: 0, gas_price: '0', value: 0, input: myTokenAbiInterface.encodeFunctionData('approve', [toWalletAddress, 1234567890]), }, { from: toWalletAddress, to: myTokenAddress, gas: 0, gas_price: '0', value: 0, input: myTokenAbiInterface.encodeFunctionData('transferFrom', [ fromWalletAddress, toWalletAddress, 1234567890, ]), }, ], blockNumber: 3262454, overrides: { [myTokenAddress]: { state: { [`_balances[${fromWalletAddress}]`]: '1234567891', }, }, }, });