main’s typed parameters. The compiled bytecode holds no values for them: each cook appends the encoded arguments to the bytecode, and that whole payload is the program argument of Pot.cook(engine, program). One compiled program serves every set of values.
entryEncoding is always "abi-v1". To fix the values in the bytecode instead, pass args when compiling; see Bind arguments at compile time.
routes.encodeEntryArguments
Checks values againstmain’s declared parameters, in order, and encodes them in the layout main reads.
Import
Usage
entry-args.ts
Signature
Parameters
A value takes the form of its parameter’s type:
Returns
Uint8Array: the encoded arguments, to append to the program’s bytecode.
Throws
A wrong number of values throws aRangeError; a value that is not of its parameter’s type throws a TypeError naming the parameter:
entry-args-error.ts
routes.decodeEntryArguments
The strict inverse ofencodeEntryArguments: reads main’s arguments back from the bytes appended to the program.
Import
Usage
entry-args.ts above decodes the arguments it encoded:
Signature
Parameters
Returns
EntryValue[]: one value per declared parameter. Integers come back as bigint, an Int256 with its sign, addresses as hex, records as objects naming their fields.
Throws
ARangeError when encoded is not exactly the encoding encodeEntryArguments produces for the values it decodes to: truncated, padded or otherwise non-canonical bytes. The last line of the entry-args-error.ts output above is one.
Signed integers
AnInt256 parameter is signed. Its word is the two’s complement of the value, and it decodes with its sign:
int256-args.ts
-10n is accepted for the Int256 parameter and refused for the Uint256 one. A value outside -2^255 through 2^255 - 1 throws a TypeError naming the parameter.
ABI-v1 layout
ABI-v1 isabi.encode of main’s parameters, with no selector:
entry-args-abi.ts
main reads each parameter from one 32-byte head word, so such a record sits behind an offset word, as a dynamic parameter would. abi.encode writes its fields inline. The raw compiler marks it indirect in entryParams:
entry-args-tuple.ts
encodeEntryArguments starts with the offset word 0x40; encodeAbiParameters starts with the field amount. A program given the inline layout reverts with no data: on a local fork of Base at block 52992458 with the current contracts, this program’s cook returned 7 with encodeEntryArguments’s bytes and reverted with encodeAbiParameters’s. Encode a program with an indirect parameter with routes.encodeEntryArguments.
Raw compiler arguments
A program from the rawcompile() carries entryParams, its parameters as an ABI parameter list. When no parameter is indirect, viem’s encodeAbiParameters(entryParams, values) is the argument payload as it stands:
raw-entry-params.ts
indirect before you encode with viem, as the example does. A parameter bound with the raw args option is not in entryParams, so it takes no value. On Solana, Account parameters are not in entryParams either: they are attached accounts, which the manifest lists.
Next steps
- Compiling:
entryParams,entrySignatureand binding arguments withargs. - Cook transactions: send the payload to a Pot.
- Bytecode: what the compiled program contains.
- sauce compile and sauce tx:
--argsencodes the same way from a terminal.
