Terra Rust API

A rust API for Terrad's LCD system.

Warning

This is a WIP.

No security audit has been performed.

Randomness

The API is currently using random numbers via
let mut rng = rand::thread_rng();

Disclaimer

This may steal your money.

This is not investment advice.

Do you own research

Help ?

There is a CLI that uses this, which may be helpful

If you think this was useful, feel free to delegate to the PFC validator. It will help defray the costs.

PFC - Terra/Luna is Pretty Freaking Cool right... feel free to drop me a line

An Example

```rust use terrarustapi::{Terra, GasOptions, PrivateKey}; use terrarustapi::coretypes::{Coin, Msg, StdSignMsg, StdSignature}; use terrarustapi::messages::MsgSend; use terrarustapi::authtypes::AuthAccountResult;

// set up the LCD client let gasopts = GasOptions::createwithgasestimate("50ukrw",1.4); let t = Terra::lcdclient("https://tequila-lcd.terra.dev/", "tequila-0004", &gasopts).await?; // generate a private key let secp = Secp256k1::new(); let fromkey = PrivateKey::fromwords(&secp,"your secret words"); let frompublickey = fromkey.publickey(&secp); // generate the message SEND 1000 uluna from your private key to someone else let coin: Coin = Coin::parse("1000uluna")?.unwrap(); let fromaccount = frompublickey.account()?; let send: MsgSend = MsgSend::create(fromaccount, "terra1usws7c2c6cs7nuc8vma9qzaky5pkgvm2uag6rh", vec![coin]); // generate the transaction & calc fees let messages: Vec> = vec![Box::new(send)]; let stdfee = terra.calcfees(&messages).await?; let authresult: AuthAccountResult = terra.auth().account(&frompublickey.account()?).await?; let accountnumber = authresult.result.value.accountnumber; let stdsignmsg = StdSignMsg { chainid: terra.chainid.tostring(), accountnumber, sequence: authresult.result.value.sequence, fee: stdfee, msgs: messages, memo: "Luna to the Moon!".to_string(), };

// Sign it let js = serdejson::tostring(&stdsignmsg)?; let sig = from_key.sign(&secp, &js)?; let sigs: Vec = vec![sig];

// send it out let resp = terra.tx().broadcastsync(&stdsignmsg, &sigs).await?; match resp.code { Some(code) => { log::error!("{}", serdejson::to_string(&resp)?); eprintln!("Transaction returned a {} {}", code, resp.txhash) } None => { println!("{}", resp.txhash) } } ```