Crates.io | terra-rust-api |
lib.rs | terra-rust-api |
version | 1.2.20 |
source | src |
created_at | 2021-04-26 02:17:30.930731 |
updated_at | 2022-03-20 00:20:12.796487 |
description | Terra Rust API |
homepage | https://github.com/PFC-Validator/terra-rust/tree/main/terra-rust-api |
repository | https://github.com/PFC-Validator/terra-rust/ |
max_upload_size | |
id | 389549 |
size | 1,753,469 |
A rust API for Terrad's LCD system.
This is a WIP.
No security audit has been performed.
The API is currently using random numbers via
let mut rng = rand::thread_rng();
This may steal your money.
This is not investment advice.
Do your own research
There is a CLI that uses this, which may be helpful.
We have also set up a Discord channel to discuss this, and other PFC things
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
use terra_rust_api::{Terra, GasOptions, PrivateKey};
use terra_rust_api::core_types::{Coin, Msg, StdSignMsg, StdSignature};
use terra_rust_api::messages::MsgSend;
use terra_rust_api::auth_types::AuthAccountResult;
// set up the LCD client
let gas_opts = GasOptions::create_with_gas_estimate("50ukrw",1.4);
let t = Terra::lcd_client("https://bombay-lcd.terra.dev/", "bombay-12", &gas_opts).await?;
// generate a private key
let secp = Secp256k1::new();
let from_key = PrivateKey::from_words(&secp,"your secret words");
let from_public_key = from_key.public_key(&secp);
// generate the message SEND 1000 uluna from your private key to someone else
let coin: Coin = Coin::parse("1000uluna")?.unwrap();
let from_account = from_public_key.account()?;
let send: MsgSend = MsgSend::create(from_account, "terra1usws7c2c6cs7nuc8vma9qzaky5pkgvm2uag6rh", vec![coin]);
// generate the transaction & calc fees
let messages = vec![send];
// and submit the message(s) to the chain
let resp = terra.submit_transaction_sync(
&secp,
&from_key,
&messages,
None
)
.await?;
println!("{}", resp.txhash)
are located in the main 'terra-rust' repo
cargo run --example do_swap -- --wallet tequilla test terra13e4jmcjnwrauvl2fnjdwex0exuzd8zrh5xk29v 1.0 1000000 uluna --max-spread
0.10 --coins 1000000uluna -l https://bombay-lcd.terra.dev -c bombay-12
**(note) coins and amount need to be the same