gleeth/ethereum/types
Ethereum domain types used throughout gleeth.
Most types are hex-encoded string aliases (addresses, hashes, wei values)
matching how the JSON-RPC API represents them. Structured types like
Transaction, TransactionReceipt, and Log are decoded from RPC
responses by the methods module.
Types
A hex-encoded Ethereum address, e.g. "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045".
pub type Address =
String
An address paired with its balance.
pub type Balance {
Balance(address: String, value: String)
}
Constructors
-
Balance(address: String, value: String)
Block header information.
pub type Block {
Block(
number: String,
hash: String,
parent_hash: String,
timestamp: String,
gas_limit: String,
gas_used: String,
transactions: List(String),
)
}
Constructors
-
Block( number: String, hash: String, parent_hash: String, timestamp: String, gas_limit: String, gas_used: String, transactions: List(String), )
A hex-encoded block number, e.g. "0x10d4f1".
pub type BlockNumber =
String
Fee history data returned by methods.get_fee_history for EIP-1559 gas
estimation.
pub type FeeHistory {
FeeHistory(
oldest_block: String,
base_fee_per_gas: List(String),
gas_used_ratio: List(Float),
reward: List(List(String)),
)
}
Constructors
-
FeeHistory( oldest_block: String, base_fee_per_gas: List(String), gas_used_ratio: List(Float), reward: List(List(String)), )Arguments
- oldest_block
-
Lowest block number in the returned range.
- base_fee_per_gas
-
Base fee per gas for each block. Contains N+1 entries (includes the next block’s base fee).
- gas_used_ratio
-
Ratio of gas used to gas limit for each block (0.0 to 1.0).
- reward
-
Priority fee at requested percentiles for each block. Empty if no percentiles were requested.
Parameters for eth_estimateGas. Empty strings are omitted from the
request.
pub type GasEstimateTransaction {
GasEstimateTransaction(
from: String,
to: String,
value: String,
data: String,
)
}
Constructors
-
GasEstimateTransaction( from: String, to: String, value: String, data: String, )
An event log emitted by a smart contract.
Returned by methods.get_logs and included in TransactionReceipt.
pub type Log {
Log(
address: String,
topics: List(String),
data: String,
block_number: String,
transaction_hash: String,
transaction_index: String,
block_hash: String,
log_index: String,
removed: Bool,
)
}
Constructors
-
Log( address: String, topics: List(String), data: String, block_number: String, transaction_hash: String, transaction_index: String, block_hash: String, log_index: String, removed: Bool, )Arguments
- address
-
Contract address that emitted the log.
- topics
-
Indexed event parameters (up to 4 topics).
- data
-
Non-indexed event data (ABI-encoded).
- block_number
-
Block number where the log occurred.
- transaction_hash
-
Transaction that produced this log.
- transaction_index
-
Index of the transaction within the block.
- block_hash
-
Hash of the block containing this log.
- log_index
-
Index of this log within the block.
- removed
-
Trueif this log was removed due to a chain reorganization.
Filter parameters for eth_getLogs.
pub type LogFilter {
LogFilter(
from_block: String,
to_block: String,
address: String,
topics: List(String),
)
}
Constructors
-
LogFilter( from_block: String, to_block: String, address: String, topics: List(String), )Arguments
- from_block
-
Starting block (hex or tag like
"latest"). Empty string defaults to"latest". - to_block
-
Ending block. Empty string defaults to
"latest". - address
-
Contract address to filter. Empty string means all contracts.
- topics
-
Topic filters. Empty list means all topics.
A hex-encoded storage slot position, e.g. "0x0" for slot 0.
pub type StorageSlot =
String
A hex-encoded 32-byte storage value returned by eth_getStorageAt.
pub type StorageValue =
String
Full transaction object as returned by methods.get_transaction.
Fields that are "" (empty string) indicate null/absent values in the
JSON-RPC response - e.g. block_number is empty for pending transactions,
to is empty for contract creation.
pub type Transaction {
Transaction(
hash: String,
block_number: String,
block_hash: String,
transaction_index: String,
from: String,
to: String,
value: String,
gas: String,
gas_price: String,
max_fee_per_gas: String,
max_priority_fee_per_gas: String,
input: String,
nonce: String,
transaction_type: String,
chain_id: String,
v: String,
r: String,
s: String,
)
}
Constructors
-
Transaction( hash: String, block_number: String, block_hash: String, transaction_index: String, from: String, to: String, value: String, gas: String, gas_price: String, max_fee_per_gas: String, max_priority_fee_per_gas: String, input: String, nonce: String, transaction_type: String, chain_id: String, v: String, r: String, s: String, )Arguments
- hash
-
Transaction hash.
- block_number
-
Block number. Empty for pending transactions.
- block_hash
-
Block hash. Empty for pending transactions.
- transaction_index
-
Index within the block. Empty for pending transactions.
- from
-
Sender address.
- to
-
Recipient address. Empty for contract creation.
- value
-
Value transferred in wei.
- gas
-
Gas limit.
- gas_price
-
Gas price in wei (legacy transactions). Empty for EIP-1559.
- max_fee_per_gas
-
Max fee per gas (EIP-1559). Empty for legacy transactions.
- max_priority_fee_per_gas
-
Max priority fee per gas (EIP-1559). Empty for legacy transactions.
- input
-
Input data (calldata).
- nonce
-
Sender’s nonce.
- transaction_type
-
Transaction type:
"0x0"legacy,"0x1"EIP-2930,"0x2"EIP-1559. - chain_id
-
Chain ID.
- v
-
ECDSA recovery id.
- r
-
ECDSA signature r component.
- s
-
ECDSA signature s component.
A transaction receipt returned after a transaction is mined.
Returned by methods.get_transaction_receipt.
pub type TransactionReceipt {
TransactionReceipt(
transaction_hash: String,
transaction_index: String,
block_hash: String,
block_number: String,
from: String,
to: String,
cumulative_gas_used: String,
gas_used: String,
contract_address: String,
logs: List(Log),
logs_bloom: String,
status: TransactionStatus,
effective_gas_price: String,
)
}
Constructors
-
TransactionReceipt( transaction_hash: String, transaction_index: String, block_hash: String, block_number: String, from: String, to: String, cumulative_gas_used: String, gas_used: String, contract_address: String, logs: List(Log), logs_bloom: String, status: TransactionStatus, effective_gas_price: String, )Arguments
- transaction_hash
-
Hash of the transaction.
- transaction_index
-
Index of the transaction within the block.
- block_hash
-
Hash of the block containing this transaction.
- block_number
-
Number of the block containing this transaction.
- from
-
Sender address.
- to
-
Receiver address. Empty string for contract creation.
- cumulative_gas_used
-
Total gas used in the block up to and including this transaction.
- gas_used
-
Gas consumed by this specific transaction.
- contract_address
-
Address of the created contract. Empty string if not a deployment.
- logs
-
Event logs emitted by this transaction.
- logs_bloom
-
Bloom filter for quick log retrieval by light clients.
- status
-
Whether the transaction succeeded or reverted.
- effective_gas_price
-
Actual gas price paid per unit (relevant for EIP-1559).
Status of a mined transaction (post-Byzantium).
pub type TransactionStatus {
Success
Failed
}
Constructors
-
SuccessThe transaction executed successfully (
status: 0x1). -
FailedThe transaction reverted (
status: 0x0).