zink/primitives/
properties.rs

1use super::{Address, Bytes32};
2use crate::asm;
3
4/// Get the current block number.
5pub fn number() -> u64 {
6    unsafe { asm::evm::number() }
7}
8
9/// Get the hash of one of the 256 most recent complete blocks.
10pub fn blockhash(block_number: u64) -> Bytes32 {
11    unsafe { asm::evm::blockhash(block_number) }
12}
13
14/// Get versioned hashes.
15pub fn blobhash(index: u64) -> Bytes32 {
16    unsafe { asm::evm::blobhash(index) }
17}
18
19/// Get the current block’s base fee.
20pub fn basefee() -> u64 {
21    unsafe { asm::evm::basefee() }
22}
23
24/// Get the current block’s blob base fee.
25pub fn blobbasefee() -> u64 {
26    unsafe { asm::evm::blobbasefee() }
27}
28
29/// Get the current chain id.
30pub fn chainid() -> u64 {
31    unsafe { asm::evm::chainid() }
32}
33
34/// Get the block’s beneficiary address.
35pub fn coinbase() -> Address {
36    unsafe { asm::evm::coinbase() }
37}
38
39/// Get the previous block’s RANDAO mix.
40pub fn prevrandao() -> Bytes32 {
41    unsafe { asm::evm::prevrandao() }
42}
43
44/// Get the current block gaslimit.
45pub fn gaslimit() -> Bytes32 {
46    unsafe { asm::evm::gaslimit() }
47}
48
49/// Get the amount of available gas.
50pub fn gasleft() -> Bytes32 {
51    unsafe { asm::evm::gas() }
52}
53
54/// Get the block’s timestamp.
55pub fn timestamp() -> u64 {
56    unsafe { asm::evm::timestamp() }
57}
58
59/// Get the gas price of the transaction.
60pub fn gasprice() -> u64 {
61    unsafe { asm::evm::gasprice() }
62}