Skip to main content

Interact with Cosmos

in src/main.rs:

src/main.rs
use kilnfi_connect_rs::Kiln;
use kilnfi_connect_rs::RestakeRewardsTxRequest;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_token: String = std::env::var("KILN_API_TOKEN")
.expect("KILN_API_TOKEN is not set in the environment. It is required.");

let kiln: Kiln = Kiln::builder()
.api_token(api_token)
// no trailing slash, or else it will break
.base_url("https://api.kiln.fi/v1")
.seal()
.build()?;

// The addresses are just examples.
// PLEASE DO NOT USE THESE ADDRESSES IN PRODUCTION UNLESS THESE ARE YOURS BY SOME ACCIDENT
let _data = kiln.cosmos().post_restake_rewards_tx(&RestakeRewardsTxRequest{
pubkey: String::from("cosmospub1addwnpepqt8ha594svjn3nvfk4ggfn5n3f8dx3r6u9gvfm7p8eevcyj5au63sxm7t7q"),
validator: String::from("cosmosvaloper1c4k24jzduc365kywrsvf5ujz4ya6mwympnc4en"),
grantee_address: String::from("cosmos8c5k24jzduc365kywrsvf5ujz4ya6mwymp2c8en"),
});


Ok(())
}