frame-rs
is a Rust library designed to facilitate interaction with the Frame Ethereum wallet. It provides a straightforward, asynchronous API for switching Ethereum networks via Frame's JSON-RPC interface and performing Ethereum blockchain operations, leveraging the security and user-friendliness of Frame for managing accounts and signing transactions.
- Network Switching: Programmatically switch the connected Ethereum network in Frame.
- Ethereum Operations: Simplified interface for common Ethereum operations, such as sending transactions and interacting with smart contracts, using accounts managed by Frame.
- Async/Await Support: Built with asynchronous Rust features for non-blocking I/O operations.
- Rust 1.39 or later.
- Access to Frame's JSON-RPC interface (typically via localhost).
Add frame-rs
to your Cargo.toml:
[dependencies]
frame-rs = "0.1.2"
Here's a quick example to get you started with frame-rs
:
use frame_rs::client::FrameClient;
use ethers::types::U256;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
// Initialize the Frame client
let client = FrameClient::new(U256::from(1), None).await?; // Ethereum Mainnet
// Switch to Arbitrum One
let arbitrum_chain_id = U256::from(42161);
client.switch_network(arbitrum_chain_id).await?;
println!("Successfully switched to Arbitrum One.");
Ok(())
}
To start interacting with Frame, create a FrameClient
instance:
use frame_rs::client::FrameClient;
use ethers::types::U256;
#[tokio::main]
async fn main() {
let chain_id = U256::from(1); // Example for Ethereum Mainnet
let client = FrameClient::new(chain_id, None).await.expect("Failed to create FrameClient");
}
To switch the connected network:
use frame_rs::client::FrameClient;
use ethers::types::U256;
#[tokio::main]
async fn main() {
let new_chain_id = U256::from(42161); // Example for Arbitrum One
let client = FrameClient::new(U256::from(1), None).await.expect("Failed to create FrameClient");
client.switch_network(new_chain_id).await.expect("Failed to switch network");
}
frame-rs
aims to support additional Ethereum wallet operations. Stay tuned for more features!
frame-rs
is licensed under the MIT License - see the LICENSE
file for details.