#env #blockchain #networking #barreleye

barreleye-client

Barreleye的Rust驱动程序

1个不稳定版本

0.0.1 2023年1月17日

#279 in #env

Apache-2.0

20KB
470

barreleye.rs

Barreleye的官方Rust驱动程序。

Status beta Docs Github Actions Dependency Status Crates.io License

使用方法

添加到 Cargo.toml

cargo add barreleye-client

以编程方式添加网络,以便Barreleye可以开始索引

use barreleye_client::{Barreleye, Blockchain, Env, Network};

#[tokio::main]
async fn main() {
	// Define the client
	let url = "http://127.0.0.1:22775";
	let api_key = Some("7f9e9182-122d-45e1-b4be-d73fc99e9bc9");
	let client = Barreleye::new(url, api_key);

	// Create a new network
	let rpc_endpoint = "http://127.0.0.1:8545";
	let network = Network::create(
		&client,
		"Ethereum",         // name
		"Ethereum",         // tag
		Env::Mainnet,       // env
		Blockchain::Evm,    // blockchain
		1,                  // chain id
		12_000,             // block time in milliseconds
		vec![rpc_endpoint], // rpc endpoints
		100,                // rate limiter (requests per second)
	)
	.await;

	println!("{:?}", network);
}

获取地址信息

use barreleye_client::{Barreleye, Error, Info};

#[tokio::main]
async fn main() {
	// Define the client
	let url = "http://127.0.0.1:22775";
	let api_key = None;
	let client = Barreleye::new(url, api_key);

	// Get info about the address
	match Info::get(&client, "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa").await {
		Ok(info) => println!("{:?}", info),
		Err(Error::Unavailable) => println!("Is Barreleye server running?"),
		Err(e) => println!("Error: {e}"),
	}
}

查看更多 示例

许可

Apache-2.0

依赖项

~7–20MB
~293K SLoC