Factom Rust API Client
Installation
Add to cargo.toml:
[]
= "^2"
Quickstart
use *;
// Get current block height from open node
async
Usage
See the examples folder for common workflows, or use cargo run --example to
view all those you can run.
Using default settings
let client = new;
Using the open node
// factom-walletd is at `http://localhost:8089`
let client = open_node;
Using the testnet open node
// factom-walletd is located at: 'http://localhost:8089`
let client = testnet_node;
Custom factomd and factom-walletd locations
let factomd = "https://api.factomd.net/";
let factom_walletd = "http://192.168.1.42:18089";
let client = custom_node
Retrieve a Balance
let client = factom.testnet_node;
let testnet_address = "FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q";
let response = factoid_balance.await.unwrap;
// factoid balance returns factoshis, convert
let factoids = factoshis_to_fct;
println!;
Get Entry Data
let client = factom.testnet_node;
let hash = "97c4e7adce9ed277b62adfb9fb7a31ca4778181e49dcdfebca967102dd424fbc";
let response = entry.await.unwrap;
dbg!;
Runtime
This library re-exports the tokio runtime and executor by default, to disable this
and use a different runtime modify your cargo.toml with a feature flag:
[]
= {="^2", ="no-runtime"}
Testing
Most of the functions are covered by the test modules along with all the documentation examples.
Beware that running cargo test with nocapture will produce a huge amount of output.
For many of the tests to pass you will need to be running factom-walletd, any
test transactions or addresses are cleaned up afterward.
See the testing readme for instructions.
Benchmarking
A criterion benching harness is provided, if gnuplot is installed it will also automatically
generate plots for any benchmarks run, they can be found at <LIBRARY>/target/criterion/report/index.html. This
can be used to test the performance of factomd, factom-walletd, network connections
and the library functions themselves. See the benches folder readme for more information.
Fuzzing
A fuzzing suite is provided using the rust implementation of American Fuzzy Lop, with appropriate setup this can be used to fuzz both the Factom rust library along with a simulated Factom network and factom-walletd. See the fuzz folder readme for more information.
Contributing
PR's welcome. Fork the library and submit to dev branch. By contributing to this library you agree to it being Apache 2.0 licensed