ash_sdk

Crates.ioash_sdk
lib.rsash_sdk
version0.4.5
sourcesrc
created_at2023-04-28 12:55:18.054607
updated_at2024-06-26 09:03:38.744951
descriptionAsh Rust SDK
homepagehttps://ash.center
repositoryhttps://github.com/AshAvalanche/ash-rs
max_upload_size
id851359
size189,868
Léo Schoukroun (leopaul36)

documentation

https://ash.center/docs/toolkit/ash-rs/introduction

README

ash_sdk Crate

ash-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.

Opinionated structs layout

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

Avalanche networks

An AvalancheNetwork is a top level struct that represents an Avalanche network. It contains the list of its AvalancheSubnets. Most of the updating methods are implemented on this struct (e.g. update_subnet, update_blockchains, etc.).

Avalanche Subnets and validators

An AvalancheSubnet is a struct that represents an Avalanche Subnet. It contains all the Subnet metadata, the list of its AvalancheBlockchains and the list of its validators (as AvalancheSubnetsValidators).

Avalanche blockchains

An AvalancheBlockchain is a struct that represents an Avalanche blockchain. It contains all the blockchain metadata.

Avalanche nodes

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.

Configuration

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 endpoints
  • mainnet-ankr and fuji-ankr use the Ankr Avalanche public endpoints
  • mainnet-blast and fuji-blast use the Blast Avalanche public endpoints

Configuration 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.

Usage

One can check out the CLI code to see examples of how to use the library.

Modules

See the docs.rs documentation for more details.

Commit count: 299

cargo fmt