मुख्य सामग्री पर जाएं
Tenderly SDK transactions को simulate करने के लिए एक Simulator क्लास प्रदान करता है। मार्गदर्शित walkthrough के लिए, simulate transactions tutorial देखें। एक simulation चलाने के लिए, tenderly इंस्टेंस पर simulator namespace में simulateTransaction मेथड को कॉल करें:
example.js
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 मेथड को कॉल करके transactions के एक bundle को भी simulate कर सकते हैं:
example.js
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',
      },
    },
  },
});