Expand description
Execution context accessors for contract runtime information.
This module provides functions to query the current execution context, including caller information, block data, and call parameters.
§Available Context
- Caller: Who invoked this contract
- Owner: Who deployed/owns this contract
- Contract ID: This contract’s address
- Block data: Current height and timestamp
- Call value: Native tokens sent with the call
- Calldata: Function selector and arguments
§Example
ⓘ
use truthlinked_sdk::context;
fn handle_execute() -> Result<()> {
let caller = context::caller()?;
let owner = context::owner()?;
// Only owner can call this function
if caller != owner {
return Err(Error::new(ERR_UNAUTHORIZED));
}
let height = context::block_height()?;
let value = context::call_value()?;
// Process transaction...
Ok(())
}Functions§
- block_
height - Returns the current block height.
- block_
timestamp - Returns the current block timestamp (Unix seconds).
- call_
value - Returns the amount of native tokens sent with this call.
- calldata
- Returns the raw calldata (function selector + arguments).
- caller
- Returns the account ID of the transaction sender.
- contract_
id - Returns this contract’s account ID.
- owner
- Returns the account ID of the contract owner.
- set_
return_ data - Sets the return data for this contract call.
Type Aliases§
- Account
Id - Type alias for 32-byte account identifiers.