Skip to content

Latest commit

 

History

History
60 lines (51 loc) · 5.28 KB

File metadata and controls

60 lines (51 loc) · 5.28 KB

std module

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

Configuration variables

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

Variable Type Default Description
$std:tokenlist string https://api.evmcrispr.com/tokenlist/{chainId} Tokenlist URL used to resolve token symbols (must be HTTPS).
$std:ipfsJwt string Pinata JWT used by @ipfs to upload content.

Commands

Command Description
batch Group multiple commands into a single transaction.
def Define a user command, helper, or module (def module <name> ( ...defs )), or return early from a command body (def return).
exec Call a contract function, encoding the arguments from its signature.
exit Stop script execution immediately.
if Conditionally execute a block of commands, with an optional else block.
load Load a module. Its commands and helpers become available qualified (mod:cmd, @mod:helper); an import list makes selected names available unqualified.
loop Repeat 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).
print Log 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.
send Send a low-level transaction. Provide [to] for a call/transfer, --data for raw calldata, --value for native value, or any combination.
set Assign a value to a variable for use later in the script.
sign Sign a message or typed data with the connected wallet.
switch Switch the active chain by name or ID.
wait Wait for a duration before executing the next action (fork simulations advance the chain's clock instead).

Helpers

Helper Returns Description
@abi.decode array Decode ABI-encoded bytes into values given a comma-separated type list.
@abi.decodeCall array Decode calldata into [contract signature [args]] with human-readable EVML values.
@abi.encode bytes ABI-encode values given a comma-separated type list, like Solidity abi.encode.
@abi.encodeCall bytes ABI-encode a function call from its signature and arguments.
@abi.encodePacked bytes ABI non-standard packed encoding, matching Solidity's abi.encodePacked.
@arr array Generate an array of sequential integers from start (inclusive) to end (exclusive).
@block array Return [number, timestamp] of the latest or a specific block.
@bool bool Evaluate a boolean expression or convert a value to a boolean string.
@bytes bytes Convert a value to hex bytes, force UTF-8 encoding, or perform a bitwise operation.
@bytes32 bytes32 Pad 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.
@date number Parse a date string into a Unix timestamp, with an optional offset.
@ens address Resolve an ENS name to its address.
@gas.estimate number Estimate the gas required for a contract call.
@gas.price number Return the current gas price in wei.
@get any Call a read-only contract function and return its result.
@hash bytes32 Compute the hash of a string with keccak256 (default) or sha256.
@ipfs string Upload text content to IPFS and return the CID.
@ipfs.get string Fetch content from IPFS and return it as text.
@me address Return the connected wallet address.
@nonce number Get the transaction count (nonce) of an address.
@num number Evaluate an arithmetic expression or convert a value to a number.
@sigValid bool Verify a signature against an expected signer address. Auto-detects EIP-712 typed data (JSON) vs. plain message.
@str string Convert a value to its string representation, or decode hex bytes as UTF-8.
@token address Resolve a token symbol to its contract address on the current chain.