| Crates.io | xbyte-evm |
| lib.rs | xbyte-evm |
| version | 0.1.1 |
| created_at | 2026-01-05 17:12:28.12099+00 |
| updated_at | 2026-01-05 18:03:18.518396+00 |
| description | xByte Infra |
| homepage | |
| repository | https://github.com/Arvmor/xbyte |
| max_upload_size | |
| id | 2024261 |
| size | 122,134 |
A Rust library for interacting with xByte smart contracts on EVM-compatible chains. This crate provides type-safe bindings and utilities for the xByte Factory, Vault, and Relay contracts.
Add this to your Cargo.toml:
[dependencies]
xbyte-evm = "0.1.0"
use xbyte_evm::{Client, Factory, Vault};
use alloy_primitives::Address;
// Initialize a client
let client = Client::new("https://sepolia.base.org")?;
// Get a factory instance
let factory = client.clone().get_factory();
// Compute a vault address for an owner
let owner = address!("d6404c4d93e9ea3cdc247d909062bdb6eb0726b0");
let vault_address = Factory::<()>::compute_vault(owner);
// Interact with a vault
let vault = Vault::new(vault_address, client);
use xbyte_evm::{Client, Factory};
let client = Client::new("https://sepolia.base.org")?;
let factory = client.clone().get_factory();
// Create a new vault (requires transaction signing)
let tx = factory.createVault().send().await?;
let receipt = tx.get_receipt().await?;
use xbyte_evm::Factory;
use alloy_primitives::Address;
let owner = address!("d6404c4d93e9ea3cdc247d909062bdb6eb0726b0");
let vault_address = Factory::<()>::compute_vault(owner);
ClientThe main client for connecting to EVM networks.
pub struct Client(DynProvider<Ethereum>);
impl Client {
pub fn new(url: &str) -> anyhow::Result<Self>;
pub fn get_factory(self) -> Factory<Self>;
pub fn get_relay(self, address: Address) -> Relay<Self>;
}
FactoryInterface for the xByteFactory contract.
pub struct Factory<P>(xByteFactory::xByteFactoryInstance<P>);
impl<P: Provider> Factory<P> {
pub fn new(provider: P) -> Self;
}
impl<P> Factory<P> {
pub const ADDRESS: Address;
pub const RELAY_ADDRESS: Address;
pub fn compute_vault(owner: Address) -> Address;
}
The Factory implements Deref to xByteFactory::xByteFactoryInstance<P>, giving you access to all contract methods.
VaultInterface for the xByteVault contract.
pub struct Vault<P>(xByteVault::xByteVaultInstance<P>);
impl<P: Provider> Vault<P> {
pub fn new(address: Address, provider: P) -> Self;
}
The Vault implements Deref to xByteVault::xByteVaultInstance<P>, giving you access to all contract methods.
RelayInterface for the xByteRelay contract.
pub struct Relay<P>(xByteRelay::xByteRelayInstance<P>);
impl<P: Provider> Relay<P> {
pub fn new(address: Address, provider: P) -> Self;
}
The Relay implements Deref to xByteRelay::xByteRelayInstance<P>, giving you access to all contract methods.
This crate provides Rust bindings for three main contracts:
The bindings are generated from Solidity contracts using Alloy's sol! macro, providing type-safe, zero-cost abstractions over the contract ABIs.
The factory contract address is hardcoded as a constant:
Factory::ADDRESS // 0x4957cDc66a60FfBf6E78baE23d18973a5dcC3e05
Factory::RELAY_ADDRESS // 0xe6d1316B8BBe88B0dc0A67ae754d1A5ce296C1Da
use xbyte_evm::{Client, Factory};
use alloy_primitives::Address;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let client = Client::new("https://sepolia.base.org")?;
let factory = client.clone().get_factory();
// Compute vault address before creation
let owner = address!("d6404c4d93e9ea3cdc247d909062bdb6eb0726b0");
let computed = Factory::<()>::compute_vault(owner);
// Verify with on-chain computation
let on_chain = factory.computeVaultAddress(owner).call().await?;
assert_eq!(computed, on_chain);
Ok(())
}
Since the types are generic over Provider, you can use any Alloy-compatible provider:
use xbyte_evm::Factory;
use alloy_provider::Provider;
fn use_custom_provider<P: Provider>(provider: P) -> Factory<P> {
Factory::new(provider)
}
cargo test
cargo build --release
The contract bindings are automatically generated from Solidity files in the contracts/ directory using Alloy's sol! macro. To update bindings, modify the Solidity contracts and rebuild.
alloy-sol-types - Solidity type systemalloy-contract - Contract interaction utilitiesalloy-provider - EVM provider abstractionalloy-primitives - EVM primitive typesanyhow - Error handlingSee the workspace root for license information.