algonaut 0.8.0

A Rusty sdk for the Algorand blockchain.
Documentation
use algonaut::Algod;
use algonaut::core::{Round, StateProofPk, VotePk, VrfPk};
use algonaut::transaction::RegisterKey;
use algonaut::transaction::account::Account;
use dotenv::dotenv;
use std::env;
use std::error::Error;
#[macro_use]
extern crate log;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    dotenv().ok();
    env_logger::init();

    info!("creating algod client");
    let algod = Algod::new(&env::var("ALGOD_URL")?, &env::var("ALGOD_TOKEN")?)?;

    info!("creating account for alice");
    let alice = Account::from_mnemonic(&env::var("ALICE_MNEMONIC")?)?;

    let vote_pk_str = "KgL5qW1jtHAQb1lQNIKuqHBqDWXRmb7GTmBN92a/sOQ=";
    let selection_pk_str = "A3s+2bgKlbG9qIaA4wJsrrJl8mVKGzTp/h6gGEyZmAg=";
    // 64-byte BLS public key required since the v34 consensus upgrade.
    let state_proof_key_str =
        "WaA5UWiVDzD6QY/ZxNi0Pc4xL4FxQa3kjlrZmkSMcEUjGFQqRGo3CSNZ9D8GAr+5e7TgQHM2RfsdJ4yLpcfkRA==";

    info!("retrieving suggested params");
    let params = algod.suggested_params().await?;

    info!("building RegisterKey transaction");
    let t = RegisterKey::online(
        alice.address(),
        VotePk::from_base64_str(vote_pk_str)?,
        VrfPk::from_base64_str(selection_pk_str)?,
        StateProofPk::from_base64_str(state_proof_key_str)?,
        params.last_round,
        Round(params.last_round.0 + 3_000_000),
        10_000,
    )
    .build(&params)?;

    info!("signing transaction");
    let sign_response = alice.sign(t)?;

    info!("broadcasting transaction");
    // Broadcast the transaction to the network
    // Note this transaction will get rejected because the accounts do not have any tokens
    let send_response = algod.send(&sign_response).await;
    info!("{:?}", send_response);

    Ok(())
}