Example: Simulate new transaction

Let’s use an example to explain how to simulate an arbitrary transaction on Walnut.

Let’s suppose we want to create a new transaction simulation that will call the increase_balance method on the following contract on the Sepolia network: 0x03f09656761d212cdcc05f1479c914491f6096a9396fe8a6acfb6bb2351b845c.

Entrypoint we intend to call:

    fn increase_balance(ref self: TContractState, amount: felt252)

Step 1: Prepare Calldata for Walnut Simulation Form

Step 1.1: Calculate the Function Selector

Use starkli to generate the function selector for increase_balance:

    starkli selector increase_balance

The result is: 0x0362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320

Step 1.2: Identify the Function Arguments

The increase_balance function accepts 1 Argument named amount of type felt252. So, the value for amount can be 3, encoded as:

  0x3

Step 1.3: Combine the data

Combine all components and get the Calldata for Walnut Simulation Form:

 0x1
 0x03f09656761d212cdcc05f1479c914491f6096a9396fe8a6acfb6bb2351b845c
 0x0362398bec32bc0ebb411203221a35a0301193a96f317ebe5e40be9f60d15320
 0x1
 0x3

Step 2: Simulate the Transaction

Step 2.1 Navigate to the Simulation Page

Go to Walnut and click on "Simulate Transaction".

Step 2.2 Fill in the Form Fields

  • Sender Address: Enter your account address.
  • Calldata: Paste the prepared calldata from Step 1.
  • Block Number: Optionally, specify a block number. If left blank, Walnut will use the latest block.
  • Chain: Choose SN_SEPOLIA, as the contract is deployed on Sepolia.
  • Transaction Version: Set to 1 or 3, depending on your use case. Refer to the Starknet Documentation for guidance.

Step 2.3 Run the Simulation

Click "Run Simulation" and wait for the results.