apex-sdk-types
Common types and data structures for the Apex SDK ecosystem.
Overview
apex-sdk-types provides shared types, traits, and data structures used across all Apex SDK components. This crate serves as the foundation for type-safe interactions between EVM and Substrate blockchain adapters.
Features
- Cross-Chain Types: Common types that work across both EVM and Substrate chains
- Serialization: Built-in support for JSON and binary serialization via
serde - Hex Encoding: Utilities for hexadecimal encoding/decoding of blockchain data
- Error Types: Standardized error types for blockchain operations
- Account Types: Universal account and address representations
Installation
Add this to your Cargo.toml:
[]
= "0.1.3"
Usage
use ;
// Create a new account
let account = new?;
// Work with chain IDs
let ethereum_mainnet = new;
let polkadot_relay = new;
// Handle block numbers
let block = new;
// Parse addresses
let address = from_hex?;
Type Categories
Core Types
Account- Universal account representationAddress- Blockchain address abstractionChainId- Chain identifier for multi-chain supportBlockNumber- Block height representation
Cryptographic Types
Hash- Generic hash type for different hash functionsPublicKey- Public key abstractionSignature- Digital signature representation
Transaction Types
TransactionHash- Transaction identifierNonce- Account nonce for transaction orderingFee- Transaction fee representation
Serialization
All types implement serde::Serialize and serde::Deserialize:
use Account;
use serde_json;
let account = new?;
// Serialize to JSON
let json = to_string?;
// Deserialize from JSON
let deserialized: Account = from_str?;
Cross-Chain Compatibility
Types are designed to work seamlessly across different blockchain ecosystems:
use ;
// EVM-style address
let eth_address = from_hex?;
// Substrate-style address
let dot_address = from_ss58?;
// Both work with the same API
println!;
println!;
Error Handling
Comprehensive error types for robust error handling:
use ;
Development
Building
Testing
Documentation
Integration
This crate is automatically included when you use any of the higher-level Apex SDK crates:
apex-sdk- Main SDKapex-sdk-core- Core functionalityapex-sdk-evm- EVM adapterapex-sdk-substrate- Substrate adapter
License
Licensed under the Apache License, Version 2.0. See LICENSE for details.
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.