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.USDCis the Pot’s balance of the chain’sUSDCtoken, andUSDC.balanceOf(to)the recipient’s. On Arc, where USDC is also the native coin, both read the six-decimal token;pot.balancewould read the 18-decimal coin.receivedis measured at the recipient, not assumed from the transfer. Therequire(received == amount, ...)line reverts the cook for a token that takes a fee on transfer.mainreturnsUint256, sosauce simulatedecodes the return value and prints it asmain returns Uint256: ....- Each
requirecarries a reason. A reverted simulation prints that reason, which is what--expect-revertmatches.
Run the example
1
Compile
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 to0x7099…79C8. Nothing was signed or sent.
main returned as 1000000.
On the same fork, the guard, with a Pot holding 0.5 USDC:
--expect-revert exited 0 because the reason matched.
Next steps
- Pay a list of recipients: the same payment in a loop, with a cap on the total
- Payroll by weight: split one budget by weight
- Native USDC payment on Arc: pay as native value on Arc
sauce simulate,sauce run, Names
