- Support transfer transactions for the top 100 tokens by market cap and TVL, including: BTC, ETH, USDT, BNB, SOL, USDC, TON, etc. Correspondingly, the blockchains to be integrated include: Bitcoin, Ethereum, Solana, as well as L2 networks on various chains.
- Implement cross-platform compilation for wide compatibility. Language choice limited to C/C++/Rust due to source code and toolchain considerations.
- PublicKey
- PrivateKey
- Address
- Amount
- Transaction
- Network
- Format
anychain-core, as a comprehensive abstract Trait, defines the following common methods:
pub trait PublicKey {
fn from_private_key(private_key: &Self::PrivateKey) -> Self;
fn to_address(&self, format: &Self::Format) -> Result<Self::Address, AddressError>;
}
pub trait Address {
fn from_private_key(private_key: &Self::PrivateKey, format: &Self::Format) -> Result<Self, AddressError>;
fn from_public_key(public_key: &Self::PublicKey, format: &Self::Format) -> Result<Self, AddressError>;
}
pub trait Amount {}
pub trait Format {}
pub trait Transaction {
fn new(parameters: &Self::TransactionParameters) -> Result<Self, TransactionError>;
fn sign();
fn from_bytes();
fn to_bytes(&self);
fn to_transaction_id(&self);
}
Let's take TronAddress from anychain-tron as an example:
pub struct TronAddress([u8; 21]);
impl Address for TronAddress {
type Format = TronFormat;
type PrivateKey = TronPrivateKey;
type PublicKey = TronPublicKey;
fn from_private_key(
private_key: &Self::PrivateKey,
format: &Self::Format
) -> Result<Self, AddressError> {
todo!()
}
fn from_public_key(
public_key: &Self::PublicKey,
format: &Self::Format
) -> Result<Self, AddressError> {
todo!()
}
}
By introducing the abstraction layer of anychain-core and the specific implementations of chains such as anychain-bitcoin and anychain-tron, upper-level applications can use unified code and interfaces to call the anychain SDK.
Platform | Target File Format |
---|---|
iOS | .a (Static Library) |
Android | .so (Shared Object) |
Web/Wasm | .wasm (WebAssembly) |
Windows | .dll (Dynamic-Link Library) |
macOS | .dylib (Dynamic Library) |
Embedded Devices | ELF (Executable and Linkable Format) |
Trusted Execution Environment (TEE) | .eif (Encrypted Image File) |
+-------------------+
| iOS Application |
+-------------------+
|
| Link
v
+-------------------+
| C Library (.dylib)|
+-------------------+
|
| FFI
v
+-------------------+
| Rust Library |
+-------------------+
|
| Compile
v
+-------------------+
| Rust Source Code |
+-------------------+
- Creating a Rust library
- Using FFI (Foreign Function Interface) in Rust
- Defining C-ABI functions
- Compiling the library file
- Linking the library file to the iOS application
- Handling data types
- Testing and debugging
Platform/Format | File Name | Size |
---|---|---|
Docker image | enclave-server | < 17M |
WebAssembly package | anychain_wasm_bg.wasm | 81K |
STM32 | ROM | < 10M |
iOS | anychain-ethereum-cli | 7.4M |
In comparison, web3.js/node_modules requires the inclusion of third-party packages up to 29M
- Private Key
- Public Key
- Mnemonic
- Seed
- Extended Key
- Extended Private Key
- Extended Public Key
- Derivation Path
These utility functions are used to support wallet generation for various blockchains.