Crates.io | cosmos-client |
lib.rs | cosmos-client |
version | 0.1.9 |
source | src |
created_at | 2023-06-15 15:26:54.345694 |
updated_at | 2023-08-02 09:16:23.256517 |
description | Cosmos-SDK rust rpc client |
homepage | |
repository | |
max_upload_size | |
id | 891214 |
size | 215,441 |
CosmosClient is a Rust RPC and signing client for Cosmos SDK, inspired by cosmjs in JavaScript. It is built on top of cosmrs and aims to provide a simplified and user-friendly interface for interacting with the Cosmos SDK blockchain.
To use CosmosClient in your Rust project, add the following line to your Cargo.toml file:
[dependencies]
tokio = { version = "1", features = ["full"] }
cosmos_client = "0.1"
Here's a quick example to get you started with CosmosClient:
use cosmos_client::client::Rpc;
use cosmos_client::cosmos_sdk::cosmos::base::v1beta1::Coin;
use cosmos_client::error::CosmosClient;
use cosmos_client::signer::Signer;
#[tokio::main]
async fn main() -> Result<(), CosmosClient> {
let mut client = Rpc::new("https://rpc-cosmoshub-ia.cosmosia.notional.ventures/").await?;
let signer = Signer::from_mnemonic("PUT your 24 words Here", "cosmos", "uatom", None, 30, 25_000)?;
let address = signer.public_address.to_string();
client.attach_signer(signer).await?;
println!("signer loaded for {address}");
let response = client
.send(
address.as_str(),
vec![Coin {
denom: "uatom".to_string().parse()?,
amount: 1_000_000.to_string(),
}],
None,
)
.await?;
println!("response {response:#?}");
Ok(())
}
Please note that this is a simplified example and may not cover all available functionality. Refer to the documentation and examples for more advanced usage and features.
The CosmosClient project includes an examples directory that contains various examples showcasing the usage of the library. These examples are designed to help developers quickly understand and utilize the different features and functionalities provided by CosmosClient.
To run the examples, navigate to the examples directory and execute the desired example using the Rust package manager, Cargo. For example:
cd examples
cargo run --example auto_compound
Feel free to modify and experiment with the examples to suit your specific needs. They serve as a great starting point for building your own applications on top of CosmosClient.
For more information on the available examples and their usage, refer to the documentation or directly explore the
source code in the examples
directory.
For detailed usage instructions, API reference, and examples, please refer to the CosmosClient Documentation.
Contributions to CosmosClient are welcome! If you would like to contribute, please follow these steps:
CosmosClient is distributed under the MIT License. See the LICENSE file for more information.
CosmosClient is built on top of the cosmrs library, and we would like to express our gratitude to the authors and contributors of cosmrs for their work and contributions to the Rust Cosmos SDK ecosystem.
If you have any questions, suggestions, or feedback, please feel free to reach out to us at
Happy coding with CosmosClient!