π A comprehensive Rust toolkit for interacting with blockchain networks, focused on efficient integration with the Endless blockchain platform.
Chain Tools is a high-performance Rust workspace project that provides a complete client solution for the Endless blockchain. The project adopts a modular design, offering a full suite of features from account management to transaction processing.
chain-tools/
βββ Cargo.toml # Workspace configuration
βββ README.md # Project documentation
βββ endless-client/ # Endless blockchain client library
βββ src/
β βββ client/ # Enhanced client implementation
β βββ sdk_ext/ # SDK extensions
β βββ utils/ # Utility functions
β βββ error.rs # Error definitions
βββ Cargo.toml
- Private Key Recovery: Support for Ed25519 key local recovery
- Account Creation: Local account creation and management
- Address Generation: Automatic generation of corresponding account addresses
- Chain Information Retrieval: Get chain ID, version, and other basic information
- Smart Caching: Built-in Chain ID caching mechanism
- Transaction Submission: Support for Entry Function calls
- View Functions: Read-only function call support
- EDS Transfers: Native token transfer functionality
- Token Transfers: Support for Fungible Asset standard token transfers
- Balance Queries: Query EDS and other token balances
- Transaction Simulation: Simulate transactions before actual execution
- Gas Configuration: Custom gas limits and pricing
- Timeout Management: Flexible transaction timeout settings
- Error Handling: Comprehensive error classification and handling mechanisms
- Async Support: Built on Tokio async runtime
Add to your Cargo.toml:
[dependencies]
endless-client = { git = "https://github.com/Alonoril/chain-tools", branch = "main" }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "macros"] }use endless_client::client::EnhancedClient;
use endless_client::sdk_ext::account::LocalAccountExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create client
let client = EnhancedClient::new_with_url_str("https://endless-rpc-url.com")?;
// Get chain information
let index = client.get_index().await?;
println!("Chain ID: {}", index.chain_id);
Ok(())
}use endless_client::sdk_ext::account::LocalAccountExt;
// Recover account from private key
let private_key = "0x1234..."; // Your private key
let account = private_key.recover_account()?;
println!("Account Address: {}", account.address());use endless_sdk::move_types::account_address::AccountAddress;
use std::str::FromStr;
// Transfer EDS
let to_address = AccountAddress::from_str("0xrecipient_address")?;
let amount = 1000000; // 1 EDS (assuming 6 decimals)
let result = client
.transfer(&account, to_address, amount, None)
.await?;
println!("Transaction Hash: {}", result.inner().hash);
// Wait for transaction confirmation
let confirmed_tx = client.wait_for_txn(result.inner()).await?;
println!("Transaction confirmed: {}", confirmed_tx.inner().hash);// Query EDS balance
let eds_balance = client.balance_of(&account.address()).await?;
println!("EDS Balance: {}", eds_balance.inner());
// Query other token balances
let token_address = AccountAddress::from_str("0xtoken_address")?;
let token_balance = client
.get_token_balance(account.address(), token_address)
.await?;
println!("Token Balance: {}", token_balance.inner());// Transfer tokens
let token_address = AccountAddress::from_str("0xtoken_address")?;
let amount = 500000;
let result = client
.transfer_token(&account, to_address, amount, token_address, None)
.await?;
println!("Token Transfer Hash: {}", result.inner().hash);// Simulate transfer transaction
let simulation = client
.simulate_transfer(&account, to_address, amount, None)
.await?;
println!("Gas Used: {:?}", simulation.inner()[0].gas_used);
println!("Success: {}", simulation.inner()[0].success);use endless_sdk::helper_client::Overrides;
let overrides = Some(Overrides {
max_gas_amount: 200000,
gas_unit_price: 100,
expiration_timeout_secs: 60,
..Overrides::default()
});
let result = client
.transfer(&account, to_address, amount, overrides)
.await?;The main client class providing all functionality for interacting with the Endless blockchain.
new(node_url: Url) -> Selfnew_with_url_str(node_url: &str) -> AppResult<Self>
get_index() -> AppResult<IndexData>- Get basic chain information
transfer(from, to, amount, overrides) -> AppResult<Response<PendingTransaction>>transfer_token(from, to, amount, token, overrides) -> AppResult<Response<PendingTransaction>>simulate_transfer(from, to, amount, overrides) -> AppResult<Response<Vec<UserTransaction>>>simulate_transfer_token(from, to, amount, token, overrides) -> AppResult<Response<Vec<UserTransaction>>>
balance_of(owner) -> AppResult<Response<u128>>- Query EDS balanceget_token_balance(owner, token) -> AppResult<Response<u128>>- Query token balance
wait_for_txn(pending_tx) -> AppResult<Response<Transaction>>- Wait for transaction confirmationrest_client() -> RestClient- Get underlying REST client
Provides account recovery functionality for private keys and strings.
recover_account(self) -> AppResult<LocalAccount>
# Build all crates
cargo build
# Build release version
cargo build --release
# Build specific crate
cargo build -p endless-client# Run all tests
cargo test
# Run tests for specific crate
cargo test -p endless-client
# Run tests with output
cargo test -- --nocapture# Format code
cargo fmt
# Static analysis
cargo clippy
# Generate documentation
cargo doc --open- endless-sdk: Official Endless Rust SDK
- base-infra: Infrastructure utilities package
- tokio: Async runtime
- serde: Serialization framework
- reqwest: HTTP client
- moka: High-performance caching library
- url: URL handling
- hex: Hexadecimal encoding/decoding
- bcs: Binary serialization
- move-core-types: Move language core types
- Fork this repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow Rust official coding standards
- Format code using
cargo fmt - Ensure
cargo clippypasses without warnings - Add test cases for new features
- Update relevant documentation
This project is licensed under the MIT License. See the LICENSE file for details.
- v0.1.0 - Initial release
- Basic Endless client functionality
- Account management and recovery
- EDS and token transfers
- Balance query functionality
β If this project helps you, please give it a star!