Skip to main content

Simulate Transactions with Tenderly

This guide demonstrates using AbstractionKit to simulate UserOperations and raw smart contract calldata with Tenderly. Simulating transactions enables you to:

  • Test transaction behavior
  • Debug potential issues before on-chain execution
  • Verify outcomes and state changes
  • Preview transaction effects for end users before signing

Complete example: simulate-with-tenderly

Configuration

Configure the following Tenderly settings to use their services:

  1. Visit dashboard.tenderly.co
  2. Create a free account
  3. Go to Settings >> Integration
TENDERLY_ACCOUNT_SLUG=
TENDERLY_PROJECT_SlUG=
TENDERLY_ACCESS_KEY=

Simulate User Operation

import { simulateUserOperationWithTenderlyAndCreateShareLink } from "abstractionkit";

const tenderlyAccountSlug = process.env.TENDERLY_ACCOUNT_SLUG as string
const tenderlyProjectSlug = process.env.TENDERLY_PROJECT_SlUG as string
const tenderlyAccessKey = process.env.TENDERLY_ACCESS_KEY as string

const userOpSimulationLink = await simulateUserOperationWithTenderlyAndCreateShareLink(
tenderlyAccountSlug,
tenderlyProjectSlug,
tenderlyAccessKey,
chainId,
entrypointAddress,
userOperation
);

console.log("userop simulation link: ", userOpSimulationLink);

Simulate Safe CallData

import { SafeAccountV0_3_0 as SafeAccount} from "abstractionkit";

const smartAccount = SafeAccount.initializeNewAccount(
[ownerPublicAddress],
);

const metaTx: MetaTransaction = {
to: "0x0000000000000000000000000000000000000000",
value: 0n,
data: "0x",
};

const callDataSimulatedLink = await smartAccount.simulateCallDataWithTenderlyAndCreateShareLink(
tenderlyAccountSlug,
tenderlyProjectSlug,
tenderlyAccessKey,
nodeUrl,
chainId,
[metaTx],
);

console.log("calldata simulation link: ", callDataSim.callDataSimulationShareLink);