Struct pbc_contract_common::context::ContractContext
source · #[repr(C)]pub struct ContractContext {
pub contract_address: Address,
pub sender: Address,
pub block_time: i64,
pub block_production_time: i64,
pub current_transaction: Hash,
pub original_transaction: Hash,
}
Expand description
The functional and temporal context that contract invocations are called in.
Can be through of as the when and why of the current invocation.
Contains information on the caller, the current time, and various PBC specific informations, like the hash of the transaction, or the hash of the parent transaction.
Fields§
§contract_address: Address
The address of the contract being called.
Primary way for the contract to determine its own address. Will never change for any specific contract deployment.
sender: Address
The sender of the event that resulted in the currently running invocation.
In #[init]
invocations this will be the creator of the contract, and in other invocations
it will be users of the contract, possibly a contract if an invocation have occured.
block_time: i64
The monotonically rising block height of the block this invocation is executed in. Counts the number of blocks that have been produced since genesis.
Should not be used for time-outs or similar system, as block production periods are highly variadic, due to being produced on-demand, and being easily manipulated by block producers.
block_production_time: i64
The Unix time in milliseconds of the block this invocation is executed in. Monotonically rising.
Preferred for time-outs, but beware that block producers may manipulate the value slightly.
current_transaction: Hash
The hash of the event that spawned this invocation.
Guarenteed unique between all invocations.
original_transaction: Hash
The hash of the signed transaction that eventually resulted in the creation of this invocation.
The most important use of this field is to determine the address of a deployed contract.
Trait Implementations§
source§impl Debug for ContractContext
impl Debug for ContractContext
source§impl PartialEq for ContractContext
impl PartialEq for ContractContext
source§fn eq(&self, other: &ContractContext) -> bool
fn eq(&self, other: &ContractContext) -> bool
self
and other
values to be equal, and is used
by ==
.