Skip to content

std

The standard module is loaded by default. It provides core language constructs, contract interaction, control flow, and data manipulation.

Config variables are set with set (fully qualified, including the module prefix) and are only readable by their own module and the user script.

VariableTypeDefaultDescription
$std:tokenliststringhttps://api.evmcrispr.com/tokenlist/{chainId}Tokenlist URL used to resolve token symbols (must be HTTPS).
$std:ipfsJwtstringPinata JWT used by @ipfs to upload content.
CommandDescription
assertAssert that an on-chain expression satisfies a comparison, on-chain.
batchGroup multiple commands into a single transaction.
defDefine a user command, helper, on-chain helper (def @name!), or module (def module <name> ( ...defs )), or return early from a command body (def return).
execCall a contract function, encoding the arguments from its signature.
exitStop script execution immediately.
ifConditionally execute a block of commands, with an optional else block.
loadLoad a module. Its commands and helpers become available qualified (mod:cmd, @mod:helper); an import list makes selected names available unqualified.
loopRepeat a block: iterate over an array (loop $x of $arr), repeat until a condition is true (loop until <condition>), or exit/skip an iteration from inside the block (loop break, loop continue).
printLog values to the console output. Arrays render as headerless tables: a flat array as one row, an array of arrays as one row per inner array.
sendSend a low-level transaction. Provide [to] for a call/transfer, --data for raw calldata, --value for native value, or any combination.
setAssign a value to a variable for use later in the script.
signSign a message or typed data with the connected wallet.
switchSwitch the active chain by name or ID.
waitWait for a duration before executing the next action (fork simulations advance the chain's clock instead).
HelperReturnsDescription
@abi.decodeanyDecode ABI-encoded bytes into values given a comma-separated type list; a lens selects one of them.
@abi.decodeCallanyDecode calldata into [contract signature [args]] with human-readable EVML values.
@abi.encodebytesABI-encode values given a comma-separated type list, like Solidity abi.encode.
@abi.encodeCallbytesABI-encode a function call from its signature and arguments.
@abi.encodePackedbytesABI non-standard packed encoding, matching Solidity's abi.encodePacked.
@arrarrayGenerate an array of sequential integers from start (inclusive) to end (exclusive).
@balancenumberBalance in base units: the native balance for ETH, or an ERC-20 balanceOf for any token symbol or address.
@blockarray[number, timestamp] of the latest or a specific block.
@boolboolEvaluate a boolean expression or convert a value to a boolean string.
@bytesbytesConvert a value to hex bytes, force UTF-8 encoding, or perform a bitwise operation.
@bytes32bytes32Pad a value to a 32-byte hex string. Integers and arithmetic expressions are left-padded like Solidity's bytes32(uint256(...)) cast; hex strings pad left by default or right with a trailing right.
@datenumberParse a date string into a Unix timestamp, with an optional offset.
@ensaddressResolve an ENS name to its address.
@gas.estimatenumberEstimate the gas required for a contract call.
@gas.pricenumberCurrent gas price in wei.
@getanyCall a read-only contract function and return its result.
@hashbytes32Compute the hash of a string with keccak256 (default) or sha256.
@ifElseanyA ternary over live reads: cond ? then : else, evaluating only the winning branch. Parenthesized ternaries nest as branches.
@ipfsstringUpload text content to IPFS and return the CID.
@ipfs.getstringFetch content from IPFS, verified against its CID, and return it as text.
@meaddressConnected wallet address.
@noncenumberNumber of transactions sent from an address (its account nonce), read over plain RPC. For contracts it counts the CREATEs they performed. There is no on-chain form: the EVM has no nonce opcode.
@numnumberEvaluate an arithmetic expression or convert a value to a number.
@orElseanyThe value of the first read, or the second one when the first reverts.
@revertsanyWhether a live call reverts: true when the chain refuses the call, false when it resolves; -!> matches the reason and a lens selects an error argument.
@sigValidboolVerify a signature against an expected signer address. Auto-detects EIP-712 typed data (JSON) vs. plain message.
@strstringConvert a value to its string representation, or decode hex bytes as UTF-8.
@EtheraddressResolve a token symbol to its contract address on the current chain.