Expand description
§Cido Ethereum
The ethereum implementation of the cido crate.
§Ethereum specific functionality
This crate exports a procedural macro called ethereum_contract that can be used to annotate
unit structs. The following is an example of how to use the macro.
// A module should contain the macro as all the structs representing all the events and
// functions in this contract are created in the same namespace as the contract struct.
mod uniswap_v3 {
pub const UNISWAP_V3_FACTORY: H160 =
H160::from_hex_str("0x1F98431c8aD98523631AE4a59f267346ea31F984");
#[ethereum_contract(
// (required) path to abi json file from the directory that contains Cargo.toml
source = "../abis/uniswap_v3_factory.json",
// Events from the contract that we're interested in
events = [PoolCreated],
// Order of processing. If set to 1 then address is also required. If 2 or 3 then
// the filters for following these events will need to be created in a generator
order = 1,
// Address of the contract if known. For now it only takes identifiers so a const will
// need to be created that can be used here
address = UNISWAP_V3_FACTORY,
)]
// The unit struct. This will have some internal fields added
pub struct UniswapV3Factory;
}The struct annotated with #[ethereum_contract(...)] will have all the functions from the
abi added to it. They can be called after creating an instead of the struct by calling bind
ⓘ
async fn handle_event(cx: Context<'_, Uniswap>, meta: MetaEvent<Uniswap>) -> Result<(), UniswapError> {
let factory = UniswapV3Factory::bind(cx.network(), meta.block_number(), UNISWAP_V3_FACTORY);
let first_pair = factory.allPairs(0).await?;
}A complete working example of using cido to index all of the uniswap-v2 events is in the examples folder under uniswap-v2.
Re-exports§
pub use cido::prelude::*;
Modules§
Structs§
- Access
List Item - Represents an
AccessListItemfor a transaction - Block
Header - The header of a block
- Block
Query - Struct that allows querying blocks from a node
- Call
- Call response
- Call
Result - Call Result
- Call
Trigger - Trigger returned when a call is matched
- Create
- Create response
- Create
Result - Craete Result
- EthCall
Args - Arguments required to make an eth_call
- Ethereum
Block - Implementation of a block for ethereum
- Ethereum
Block Number - Represents the block height of a block. Valid range is
0..2**40 - Ethereum
Block Number Range - Implementation of the
BlockNumberRangetrait for ethereum - Ethereum
Call - Represents the result of a function call on the block chain
- Ethereum
Call Filter - Filter to emit a
CallTriggeras an event for handling - Ethereum
Error - Error returned by public functions. None of these are recoverable in handler code.
- Ethereum
Event Order - Implementation of the
EventOrdertrait for ethereum - Ethereum
Init Config - Configuration for specifying rpc nodes, etc. for ethereum compatible networks
- Ethereum
LogFilter - Matches any log that matches both the address (if specified) and event signature.
- Ethereum
Network - Implementation of the
Networktrait for ethereum - Ethereum
Trigger Generator - implementation of the
TriggerGeneratortrait for ethereum - Full
Block Query - Struct that allows querying full blocks from a node
- Log
- Represents a log emitted by a contract
- LogTrigger
- Event emitted by a
LogorAllLogsEthereumFilter - Receipt
- Represents the result of a transaction once complete
- Reward
- Reward action
- Suicide
- Suicide
- Trace
- Trace-Filtering API trace type
- Transaction
- Represents a transaction within a block
- Transaction
Trigger - Event emitted by a matching
TransactionorAllTransactionsEthereumFilter - Void
- Used to indicate that a transaction has no receipt information
Enums§
- Action
- Action
- Ethereum
Block Filter - Filters available to a block
- Ethereum
Block Id - Different ways to refer to a block
- Ethereum
Event Index - Digestable information about an
EthereumEventOrder - Ethereum
Filter - Filters supported by the
Networkimplementation - Ethereum
Transaction Filter - Filters available to transactions
- Ethereum
Trigger - All types of triggers available to this crate
- Res
- Response for call or create
Traits§
- Receipt
Data - Trait to indicate whether receipt data is included in the transaction data
- Transaction
Data - Allows for a Block to be generic over how much transaction data it carries.
Type Aliases§
- AbiAddress
- Alias to
H160 - AbiHash
- Alias to
H256 - AbiInt
- Alias to
U256 - AbiUint
- Alias to
U256 - H64
- H64 wrapper for
[u8; 8] - H160
- H160 wrapper for
[u8; 20] - H256
- H256 wrapper for
[u8; 32] - H512
- H512 wrapper for
[u8; 64] - H2048
- H2048 wrapper for
[u8; 256] - Receipt
Block - Alias for
EthereumBlock<Transaction<Receipt>>or a block that contains all transaction and receipt data - Receipt
Transaction - Alias for
Transaction<Receipt>or a transaction that contains receipt data - Transaction
Block - Alias for
EthereumBlock<Transaction<Void>>or a block that contains all transaction data but no receipt data - Transaction
IdBlock - Alias for
EthereumBlock<H256>or a block that contains only transaction hashes - U64
- Alias to
U<1> - U256
- Alias to
U<4>
Attribute Macros§
- ethereum_
contract - Proc macro for creating types and functions to interact with a contract from a json abi file