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
batchGroup multiple commands into a single transaction.
defDefine a user command, helper, or module (def module <name> ( ...defs )).
execCall a contract function, encoding the arguments from its signature.
haltStop 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) or until a condition is true (loop until <condition>).
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.decodearrayDecode ABI-encoded bytes into values given a comma-separated type list.
@abi.decodeCallarrayDecode 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).
@blockanyReturn [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.
@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.pricenumberReturn the current gas price in wei.
@getanyCall a read-only contract function and return its result.
@idbytes32Compute the keccak256 hash of a string (first 4 bytes for selectors).
@ipfsstringUpload text content to IPFS and return the CID.
@ipfs.getanyFetch content from IPFS and return it as text.
@meaddressReturn the connected wallet address.
@noncenumberGet the transaction count (nonce) of an address.
@numnumberEvaluate an arithmetic expression or convert a value to a number.
@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.
@tokenaddressResolve a token symbol to its contract address on the current chain.
@token.allowancenumberFetch the allowance an owner has granted to a spender, in base units.
@token.amountnumberConvert a human-readable token amount to its base unit (applying decimals).
@token.balancenumberFetch the token balance of an address in base units.
@token.decimalsnumberReturn the number of decimals of a token.
@token.formatstringFormat a base-unit token amount as a human-readable string with the token symbol.
@token.symbolstringReturn the symbol of a token.
@token.totalSupplynumberFetch the total supply of a token in base units.