मुख्य सामग्री पर जाएं
simulation_type API पैरामीटर आपको Simulation API परिणाम में लौटाई गई जानकारी के विवरण के स्तर को नियंत्रित करने की अनुमति देता है। यह single simulations और bundled अनुरोधों दोनों पर लागू होता है।

Simulations के प्रकार

  • full (डिफ़ॉल्ट): call trace, function inputs और outputs, state diffs आदि के साथ विस्तृत raw और decoded जानकारी।
  • quick: न्यूनतम, raw मान
  • abi: decoded inputs, outputs, और logs के साथ न्यूनतम जानकारी
Full simulations में call trace की गहराई के आधार पर अधिक समय लगता है। जब decoded जानकारी आवश्यक न हो तो quick simulations का उपयोग करें।

Full simulation मोड

  • Call trace जिसमें function का नाम, source फ़ाइल में स्थिति, caller का पता, और balance शामिल हैं
  • सभी argument के लिए soltype के साथ decoded function inputs और outputs। यह सभी function कॉल्स पर लागू होता है, जिसमें EOA से smart contract के लिए सीधे कॉल, smart contracts के बीच internal कॉल, और प्रत्येक smart contract के भीतर function कॉल्स शामिल हैं।
  • संशोधित फ़ील्ड के लिए soltype से समृद्ध decoded state diff (state में परिवर्तन)
  • Decoded logs (events) जिनमें उन्हें उत्पन्न करने वाला Solidity event और event argument का value शामिल है, प्रत्येक के लिए type से समृद्ध।
request.ts

dotenv.config();

const approveDai = async () => {
  // assuming environment variables TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG and TENDERLY_ACCESS_KEY are set
  // https://docs.tenderly.co/platform/account/projects/slug
  // https://docs.tenderly.co/platform/account/projects/api-tokens
  const { TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG, TENDERLY_ACCESS_KEY } = process.env;

  console.time('Simulation');

  const resp = await axios.post(
    `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate`,
    // the transaction
    {
      /* Simulation Configuration */
      save: false, // if true simulation is saved and shows up in the dashboard
      save_if_fails: false, // if true, reverting simulations show up in the dashboard
      simulation_type: 'full', // full, abi or quick (full is default)
      network_id: '1', // network to simulate on
      /* Standard EVM Transaction object */
      from: '0xdc6bdc37b2714ee601734cf55a05625c9e512461',
      to: '0x6b175474e89094c44da98b954eedeac495271d0f',
      input: '0x095ea7b3000000000000000000000000f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1000000000000000000000000000000000000000000000000000000000000012b',
      gas: 8000000,
      value: 0,
    },
    {
      headers: {
        'X-Access-Key': TENDERLY_ACCESS_KEY as string,
      },
    },
  );
  console.timeEnd('Simulation');

  const transaction = resp.data.transaction;
  console.log(JSON.stringify(transaction, null, 2));
};

approveDai();

Quick simulation मोड

अतिरिक्त decoding के बिना raw डेटा प्रदान करता है। यह मोड सबसे अच्छा तब है जब आपको केवल transaction के मूलभूत विवरण चाहिए।
request.ts

dotenv.config();

const approveDai = async () => {
  // assuming environment variables TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG and TENDERLY_ACCESS_KEY are set
  // https://docs.tenderly.co/platform/account/projects/slug
  // https://docs.tenderly.co/platform/account/projects/api-tokens
  const { TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG, TENDERLY_ACCESS_KEY } = process.env;

  console.time('Simulation');

  const resp = await axios.post(
    `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate`,
    // the transaction
    {
      /* Simulation Configuration */
      save: false, // if true simulation is saved and shows up in the dashboard
      save_if_fails: false, // if true, reverting simulations show up in the dashboard
      simulation_type: 'quick', // full, abi or quick (full is default)
      network_id: '1', // network to simulate on
      /* Standard EVM Transaction object */
      from: '0xdc6bdc37b2714ee601734cf55a05625c9e512461',
      to: '0x6b175474e89094c44da98b954eedeac495271d0f',
      input: '0x095ea7b3000000000000000000000000f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1000000000000000000000000000000000000000000000000000000000000012b',
      gas: 8000000,
      value: 0,
    },
    {
      headers: {
        'X-Access-Key': TENDERLY_ACCESS_KEY as string,
      },
    },
  );
  console.timeEnd('Simulation');

  const transaction = resp.data.transaction;
  console.log(JSON.stringify(transaction, null, 2));
};

approveDai();

ABI simulation मोड

Call trace जिसमें function का नाम, decoded input और output वेरिएबल्स शामिल हैं Decoded logs (events) जिनमें उन्हें उत्पन्न करने वाला Solidity event और event argument का value शामिल है, प्रत्येक के लिए type विवरण से समृद्ध।
request.ts

dotenv.config();

const approveDai = async () => {
  // assuming environment variables TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG and TENDERLY_ACCESS_KEY are set
  // https://docs.tenderly.co/platform/account/projects/slug
  // https://docs.tenderly.co/platform/account/projects/api-tokens
  const { TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG, TENDERLY_ACCESS_KEY } = process.env;

  console.time('Simulation');

  const resp = await axios.post(
    `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate`,
    // the transaction
    {
      /* Simulation Configuration */
      save: false, // if true simulation is saved and shows up in the dashboard
      save_if_fails: false, // if true, reverting simulations show up in the dashboard
      simulation_type: 'abi', // full, abi or quick (full is default)
      network_id: '1', // network to simulate on
      /* Standard EVM Transaction object */
      from: '0xdc6bdc37b2714ee601734cf55a05625c9e512461',
      to: '0x6b175474e89094c44da98b954eedeac495271d0f',
      input: '0x095ea7b3000000000000000000000000f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1000000000000000000000000000000000000000000000000000000000000012b',
      gas: 8000000,
      value: 0,
    },
    {
      headers: {
        'X-Access-Key': TENDERLY_ACCESS_KEY as string,
      },
    },
  );
  console.timeEnd('Simulation');

  const transaction = resp.data.transaction;
  console.log(JSON.stringify(transaction, null, 2));
};

approveDai();