Skip to main content
The program pays amount of USDC from the Pot to each address in recipients, in order, and stops before the payment that would take the total past limit. It returns the total the recipients received, and reverts when a recipient selected for payment is the zero address, the Pot runs short before the next payment, or a recipient receives a different amount. Target chains: Base. 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-list.sauce.ts

How it works

  • recipients is an Address[] parameter, so the list is a run-time argument passed as JSON in --args; the same bytecode pays any list.
  • The cap is checked before each payment (total + amount > limit), so the loop ends with break and later recipients are not paid. The cook still succeeds.
  • The Pot’s balance is checked inside the loop, before each transfer, so a Pot that covers only some payments reverts the whole cook rather than paying a prefix of the list.
  • main returns Uint256, the sum of the measured payments, so sauce simulate prints it as main returns Uint256: ....

Run the example

1

Compile

2

Simulate

--assume-balance USDC:5 gives the Pot 5 USDC for this simulation only. With a cap of 2.5 USDC and 1 USDC each, two of the three recipients are paid.
3

Send

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

Simulation result

Simulated on a local fork of Base at block 52965104 with the current contracts, with the command above, for 0x7099…79C8, 0x3C44…93BC and 0x90F7…b906. Nothing was signed or sent.
The third payment would have taken the total to 3 USDC, past the 2.5 USDC cap, so the loop stopped after two and returned 2000000. 3 of the 5 assumed USDC stayed in the Pot.

Next steps