Skip to main content
The program pays amount of USDC from the Pot to to, reads the recipient’s balance before and after the transfer, and returns the difference. It reverts when the Pot holds less than amount or when the recipient’s balance rises by anything other than amount. Target chains: Base, Ethereum and Arc. The same source compiles for all three; the recorded simulation uses a Base fork.

Prerequisites

Install the Sauce CLI to compile and simulate. To send the transaction, configure a wallet with funds for gas and the Kitchen fee. Provide the required tokens in your Pot once it is deployed, or through --fund; see funding.

Program

pot is the Pot the program runs on, available without declaring it (Names).
pay.sauce.ts

How it works

  • pot.USDC is the Pot’s balance of the chain’s USDC token, and USDC.balanceOf(to) the recipient’s. On Arc, where USDC is also the native coin, both read the six-decimal token; pot.balance would read the 18-decimal coin.
  • received is measured at the recipient, not assumed from the transfer. The require(received == amount, ...) line reverts the cook for a token that takes a fee on transfer.
  • main returns Uint256, so sauce simulate decodes the return value and prints it as main returns Uint256: ....
  • Each require carries a reason. A reverted simulation prints that reason, which is what --expect-revert matches.

Run the example

1

Compile

Replace base with ethereum or arc. Each compile is 433 bytes, but the bytecode differs, because each carries its chain’s USDC address.
2

Simulate

--assume-balance USDC:5 gives the Pot 5 USDC for this simulation only, by state override. The output lists each transfer and each address’s net change.
3

Send

sauce tx prints the unsigned transaction instead, for your own signer:

Simulation result

Simulated on a local fork of Base at block 53122821 with the current contracts, with the command above, paying 1 USDC to 0x7099…79C8. Nothing was signed or sent.
The Pot did not exist yet, so the simulation deployed it first. The recipient’s balance rose by exactly 1 USDC, which main returned as 1000000. On the same fork, the guard, with a Pot holding 0.5 USDC:
The guard stopped the cook before any USDC moved, and --expect-revert exited 0 because the reason matched.

Next steps