cido-ethereum

Crates.iocido-ethereum
lib.rscido-ethereum
version
sourcesrc
created_at2025-01-15 07:12:55.790968+00
updated_at2025-01-31 05:36:56.931062+00
descriptionEthereum implementation of the cido Network trait
homepagehttps://cido.ai
repository
max_upload_size
id1517200
Cargo.toml error:TOML parse error at line 20, column 1 | 20 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Tyler Hawkes (tylerhawkes)

documentation

https://docs.rs/cido-ethereum

README

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.

Commit count: 0

cargo fmt