#[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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ContractContext

source§

fn eq(&self, other: &ContractContext) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ReadRPC for ContractContext

source§

fn rpc_read_from<ReadContractContext: Read>( reader: &mut ReadContractContext ) -> Self

Deserialization method for RPC arguments.
source§

impl WriteRPC for ContractContext

source§

fn rpc_write_to<WriteContractContext: Write>( &self, writer: &mut WriteContractContext ) -> Result<()>

Serialization method for RPC arguments.
source§

impl Eq for ContractContext

source§

impl StructuralPartialEq for ContractContext

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.