xavax-avalanche 0.1.0-beta

Rust implmenetation of the Avalanche transaction format, including a parser to parse data from and into native structs.
Documentation

xavax-avalanche

Test Status

A Rust implementation of the Avalanche Virtual Machine transaction format, including serialization.

xavax-avalanche in a nutshell:

  • Parsing to and from bytes that represent AVM (avalanche virtual machine) Transactions.
  • All AVM and PVM data-types.
  • CB58 Encoding/Decoding.
  • Creates byte payloads ready to be sent to avalanche nodes!

All that is missing is signing transaction and key management, and all that is taken care of by the xavax-crypto crate! (see the xavax-api crate for a full avalanche network SDK)


Some things to point out

  • xavax-avalanche is currently in very early development, but optimizations and better docs should be available not too long after release! Don't be surprised if there are bugs.

  • xavax-avalanche is fairly simple in principle and is used together with other libraries in the xavax-api crate, this includes xavax-crypto and xavax-eth (which might be upcoming)

  • All the xavax crates including xavax-avalanche are used in open-source projects by xavax, an example of which is the Metro desktop wallet.

I recommend using this library for research purposes only.


Documentation

xavax-avalanche 'n' friends will have quite a lot of documentation and examples, this includes the Metro wallet itself as an example (although the early wallet will have a lot of spaghetti code).

That being said, there are many examples that you can read about and try here:

ps, this crate is very early and I am lazy so I'm future-proofing this README, some of these links may be temporarily invalid as a result...


Usage

At first, add this to your Cargo.toml file:

[dependencies]
xavax-avalanche = "0.1.2"

You could create a base transaction, among other transactions:

use xavax_avalanche::avm::tx_format::*;

//Create a base tx
let mut tx: BaseTx = BaseTx::default();
//Manually set the values
tx.type_id = 0;
tx.network_id = 5;

//Or parse a byte-payload into a base_tx:
let mut tx: BaseTx = BaseTx::default();

let tx_bytes: Vec<u8> = [0, 0, 0, 0, 0, 0, 0, 0, 0,].to_vec();
tx.from_bytes(&tx_bytes);

ps: the xavax-api which might still be upcoming will automatically generate different transactions types

Then go read some examples, maybe watch the tutorial videos that I might make some day, and experiment!

Although I heavily recommend checking out the full xavax-api crate, as this crate alone simple handles transaction formats for the Avalanche virtual machine!


Changes, Roadmap & Info

The entire xavax-api with its dependencies such as xavax-avalanche are very, very early, while I will try to keep the main API fairly consistent and stable, the back-end will get a lot of optimizations in the future. Not to mention the addition of better docs.

More information about the future as well as a roadmap of the api can be found at the xavax

Temorary note:

The API is unfinished at the current time, if you want more information about what the full API will be you can follow me at twitter, or look at the xavax introduction blog.


License

xavax-avalanche is distributed with the Apache 2.0 License.