Crates.io | ash_sdk |
lib.rs | ash_sdk |
version | 0.4.5 |
source | src |
created_at | 2023-04-28 12:55:18.054607 |
updated_at | 2024-06-26 09:03:38.744951 |
description | Ash Rust SDK |
homepage | https://ash.center |
repository | https://github.com/AshAvalanche/ash-rs |
max_upload_size | |
id | 851359 |
size | 189,868 |
ash_sdk
Crateash-rs
is a Rust SDK for Avalanche and Ash tools.
It provides a higher level of abstraction than avalanche-types-rs and comes with a CLI that simplifies the interaction with Avalanche networks.
The library provides an opinionated layout to represent Avalanche networks, Subnets and blockchains. The layout could be represented as follows:
AvalancheNetwork
└── subnets
├── AvalancheSubnet 1
│ ├── blockchains
│ │ ├── AvalancheBlockchain 1
│ │ └── AvalancheBlockchain 2
│ └── validators
│ ├── AvalancheSubnetValidator 1
│ └── AvalancheSubnetValidator 2
└── AvalancheSubnet 2
├── blockchains
│ ├── AvalancheBlockchain 3
│ └── AvalancheBlockchain 4
└── validators
├── AvalancheSubnetValidator 1
└── AvalancheSubnetValidator 2
An AvalancheNetwork
is a top level struct that represents an Avalanche network. It contains the list of its AvalancheSubnet
s. Most of the updating methods are implemented on this struct (e.g. update_subnet
, update_blockchains
, etc.).
An AvalancheSubnet
is a struct that represents an Avalanche Subnet. It contains all the Subnet metadata, the list of its AvalancheBlockchain
s and the list of its validators (as AvalancheSubnetsValidator
s).
An AvalancheBlockchain
is a struct that represents an Avalanche blockchain. It contains all the blockchain metadata.
An AvalancheNode
is a struct that represents an Avalanche node. An AvalancheNode
is not directly linked to an AvalancheNetwork
as its metadata are retrieved directly from its endpoint.
The library relies on YAML configuration files that contains the list of known Avalanche networks. For each network, at least the P-Chain configuration has to be provided (in the Primary Network) with its ID and RPC endpoint. All the other Subnets/blockchains will be retrieved/enriched from the P-Chain.
A default configuration is embedded in the library (see conf/default.yaml) and contains the following networks:
mainnet
and fuji
use the default Avalanche public endpointsmainnet-ankr
and fuji-ankr
use the Ankr Avalanche public endpointsmainnet-blast
and fuji-blast
use the Blast Avalanche public endpointsConfiguration example:
# Default configuration of the mainnet network
avalancheNetworks:
- name: mainnet
subnets:
- id: 11111111111111111111111111111111LpoYY
controlKeys: []
threshold: 0
blockchains:
- id: 11111111111111111111111111111111LpoYY
name: P-Chain
vmType: PlatformVM
rpcUrl: https://api.avax.network/ext/bc/P
- id: 2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5
name: C-Chain
vmID: mgj786NP7uDwBCcq6YwThhaN8FLyybkCa4zBWTQbNgmK6k9A6
vmType: Coreth
rpcUrl: https://api.avax.network/ext/bc/C/rpc
- id: 2oYMBNV4eNHyqk2fjjV5nVQLDbtmNJzq5s3qs3Lo6ftnC6FByM
name: X-Chain
vmID: jvYyfQTxGMJLuGWa55kdP2p2zSUYsQ5Raupu4TW34ZAUBAbtq
vmType: AvalancheVM
rpcUrl: https://api.avax.network/ext/bc/X
Note: You can generate a configuration file with the CLI using the ash conf init
command.
One can check out the CLI code to see examples of how to use the library.
See the docs.rs documentation for more details.