token namespace emits SauceScript for token operations: ERC-20 on an EVM compile target, SPL Token on svm. It is TypeScript that writes SauceScript for a host program; a SauceScript program imports the @sauce/token library instead. token.Token.transfer({ token, to, amount }).toSauceScript("evm") returns an object whose source is a program routes.compileSauceProgram compiles. token.Token is also the root export Token.
@eco-incorp/sauce.
token.isEvmTarget
Function · @eco-incorp/sauce
token.toAddressBigint
Function · @eco-incorp/sauce
token.assertU64Range
Function · @eco-incorp/sauce
Any literal (non-"balance") amount destined for SVM must fit the SPL u64 amount field.
token.toAmountBigint
Function · @eco-incorp/sauce
token.ownerRef
Function · @eco-incorp/sauce
owner/tokenProgram default names - shared/reused across ops in one program by design (the
SPL CPI-target intern is meant to dedupe across ops, unlike per-op instance refs).
token.tokenProgramRef
Function · @eco-incorp/sauce
token.validateTransferSpec
Function · @eco-incorp/sauce
token.validateApproveSpec
Function · @eco-incorp/sauce
token.validateBalanceSpec
Function · @eco-incorp/sauce
token.assertNoDuplicateSvmRefs
Function · @eco-incorp/sauce
Rejects a duplicate SVM instance ref name across DIFFERENT ops in one Token.program(...) call - a collision would silently merge two distinct AccountPlan slots. owner/tokenProgram are
exempt (shared by design).
token.Address
Type · @eco-incorp/sauce
A 20-byte EVM address, as an ordinary 0x-prefixed hex string.
token.AddressInput
Type · @eco-incorp/sauce
Anything the token normalizers accept for an address-shaped field.
token.TokenTarget
Type · @eco-incorp/sauce
The target a token emitter writes SauceScript for: "evm", "v1" and "v12" select the ERC-20 arm and emit byte-identical text, and "svm" selects the SPL Token arm. compile()’s own target option, not this value, decides what the text is compiled for.
token.TokenOp
Type · @eco-incorp/sauce
token.SPL_TRANSFER_CHECKED
Variable · @eco-incorp/sauce
SPL Token TransferChecked instruction discriminant.
token.SPL_APPROVE_CHECKED
Variable · @eco-incorp/sauce
SPL Token ApproveChecked instruction discriminant.
token.SPL_AMOUNT_OFFSET
Variable · @eco-incorp/sauce
Offset of the SPL token account’s u64 amount field (identical in classic SPL + Token-2022).
token.MINT_DECIMALS_OFFSET
Variable · @eco-incorp/sauce
Offset of the mint’s decimals byte (identical in the first 82 bytes of both programs’ mints).
token.SvmTokenRefs
Interface · @eco-incorp/sauce
SVM account refs a token op needs, as caller-named strings resolved at EXECUTION time (the same
contract svmSettleRefs establishes) - never resolved addresses baked into the source. Defaults
cover the common single-op case; a multi-op program must pass distinct names per op.
token.SvmTokenProgramInput
Type · @eco-incorp/sauce
The SVM CPI target VALUE - a well-known program id by name, or a raw pubkey as a bigint. Always a
LITERAL: every account identity a program touches is an attach slot, so a caller-supplied identity
belongs in SvmTokenRefs.tokenProgram (the ref this value is pinned against), never in the value.
token.TokenTransferSpec
Interface · @eco-incorp/sauce
token.TokenApproveSpec
Interface · @eco-incorp/sauce
token.TokenBalanceSpec
Interface · @eco-incorp/sauce
token.TokenSpec
Type · @eco-incorp/sauce
token.tokenImportLines
Function · @eco-incorp/sauce
The import lines a tokenSource(specs, target) program needs. On an EVM target: IERC20, iff
any spec is transfer/approve/balanceOf (always - every op needs the binding). On svm:
none (SVM ops use only the built-in svm.sload/svm.call globals).
token.tokenCallStatement
Function · @eco-incorp/sauce
One statement (transfer/approve) or undefined (balanceOf has no statement form - see
tokenExpression) for spec on target, for splicing into a larger, hand-written
program. Runs the full per-op/per-target validation. svmState threads dedup across multiple
ops in one program (tokenSource’s own concern) - omit it to get a fresh, single-op program.
token.tokenExpression
Function · @eco-incorp/sauce
The expression form of Token.balanceOf(spec) - the only op with one. Throws (named) for
transfer/approve, which have no meaningful expression form.
token.tokenAccountRefs
Function · @eco-incorp/sauce
The account-manifest refs a transfer/approve spec attaches, in order - mirrors
svmSettleRefs. Throws for balanceOf (a pure read; its only ref is the caller-supplied
source) and for an EVM-target spec (no account manifest on that target).
token.tokenSource
Function · @eco-incorp/sauce
A complete, compilable function main() { ... } program: one statement per transfer/approve
spec (in order), plus, if the LAST spec is a balanceOf, a trailing return <expr>; - because
Token.program’s only consumer (V12Pot.cook) executes the one program it is handed and wants
its result, if any, as the return value. A balanceOf in any OTHER position is spliced as a discarded
expression statement.
token.TokenSourceOptions
Interface · @eco-incorp/sauce
