Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Built-in

Built-in functionality refers to features available during compilation that are otherwise inaccessible through the language's regular syntax.

The parser accepts any @identifier form without validation; unknown builtin names are caught during IR lowering (semantic analysis), not parsing.

EVM environment builtins

These builtins read EVM execution context values. Each compiles to a single EnvRead IR node and a corresponding EVM opcode:

BuiltinEVM opcodeReturns
@callerCALLERAddress of the direct caller
@callvalueCALLVALUEWei sent with the call
@valueCALLVALUEAlias for @callvalue
@calldatasizeCALLDATASIZESize of calldata in bytes
@originORIGINTransaction originator address
@gaspriceGASPRICEGas price of the transaction
@coinbaseCOINBASECurrent block's beneficiary address
@timestampTIMESTAMPCurrent block's timestamp
@numberNUMBERCurrent block number
@gaslimitGASLIMITCurrent block's gas limit
@chainidCHAINIDChain ID (EIP-155)
@selfbalanceSELFBALANCEBalance of the executing contract
@basefeeBASEFEECurrent block's base fee (EIP-1559)
@gasGASRemaining gas
@addressADDRESSAddress of the executing contract
@codesizeCODESIZESize of the executing contract's code
@returndatasizeRETURNDATASIZESize of the last call's return data

All EVM environment builtins are zero-argument. Parentheses are optional: both @caller and @caller() are valid. Arguments passed to them are currently ignored.

fn checkCaller() {
    if @caller == 0x0000000000000000000000000000000000000000 {
        revert();
    }
}

Comptime builtins

These builtins execute at compile time and are used for type introspection, compile-time assertions, and code generation.

Types

type PrimitiveType;
type StructType;
type UnionType;
type FunctionType;
 
type TypeInfo =
    | Primitive(PrimitiveType)
    | Struct(StructType)
    | Union(UnionType)
    | Function(FunctionType);
type HardFork =
    | Frontier
    | Homestead
    | Dao
    | Tangerine
    | SpuriousDragon
    | Byzantium
    | Constantinople
    | Petersburg
    | Istanbul
    | MuirGlacier
    | Berlin
    | London
    | ArrowGlacier
    | GrayGlacier
    | Paris
    | Shanghai
    | Cancun;

Functions

@typeInfo

@typeInfo(typeSignature) -> TypeInfo;

Takes a single type signature as an argument and returns a TypeInfo union describing the kind of the type.

@bitsize

@bitsize(typeSignature) -> u256;

Takes a single type signature as an argument and returns the bitsize of the underlying type.

@fields

@fields(structType) -> [T, N];

Takes a single StructType as an argument and returns an array of type signatures of length N, where N is the number of fields in the struct.

@compilerError

@compilerError(errorMessage);

Emits a compile-time error with the provided message. Useful in comptime branches to enforce invariants.

@hardFork

@hardFork() -> HardFork;

Returns the target hard fork from the compiler configuration as a HardFork union value.

@bytecode

@bytecode(T -> U) -> Bytes;

Takes an arbitrary function and returns its compiled bytecode as a Bytes value. Bytes is an opaque compiler-internal type representing a sequence of raw bytes; it is not a user-definable Edge type.