Crates.io | deso-sdk |
lib.rs | deso-sdk |
version | 0.1.1 |
source | src |
created_at | 2024-05-19 02:41:38.199909 |
updated_at | 2024-06-08 02:37:20.443977 |
description | A Rust SDK for Using the Deso Blockchain |
homepage | |
repository | https://github.com/spatiumstories/deso-rust |
max_upload_size | |
id | 1244625 |
size | 32,442 |
A Rust SDK for interacting with the Deso blockchain. This library allows you to create posts, NFTs, and messages on the Deso network.
The Deso Rust SDK provides a set of utilities to interact with the Deso blockchain, enabling developers to easily perform various blockchain operations, such as creating posts, NFTs, and messages.
To create a new post on the Deso blockchain, follow these steps:
Build the Deso account: Use the DesoAccountBuilder
to create your account.
let deso_account = DesoAccountBuilder::new()
.public_key(deso_account)
.seed_hex_key(deso_private_key)
.build()
.unwrap();
Create extra data for the post: Prepare any additional data you want to include in the post.
let mut extra_data_map: HashMap<String, String> = HashMap::new();
extra_data_map.insert(String::from("nft_type"), String::from("AUTHOR"));
Build the post data: Use the SubmitPostDataBuilder
to create the post data.
let post_data = SubmitPostDataBuilder::new()
.body(String::from("Testing the new deso rust library by @Spatium!"))
.public_key(deso_account.public_key.clone())
.extra_data(extra_data_map)
.build()
.unwrap();
Create the post: Call the create_post
function with the prepared data.
let post_transaction_json = deso_sdk::create_post(&deso_account, &post_data).await.unwrap();
println!("Post created with hash: {:?}", post_transaction_json.post_entry_response.post_hash_hex);
To create a comment on an existing post, follow these steps:
Build the Deso account: Use the DesoAccountBuilder
to create your account.
let deso_account = DesoAccountBuilder::new()
.public_key(deso_account)
.seed_hex_key(deso_private_key)
.build()
.unwrap();
Prepare the post hash hex: Obtain the hash of the post you want to comment on.
let post_hash_hex = "existing_post_hash_hex".to_string();
Build the comment data: Use the SubmitPostDataBuilder
to create the comment data.
let comment_post_data = SubmitPostDataBuilder::new()
.body(String::from("cool comment bro"))
.public_key(deso_account.public_key.clone())
.parent_post_hash_hex(post_hash_hex)
.build()
.unwrap();
Create the comment: Call the create_post
function with the prepared data.
let comment_transaction_json = deso_sdk::create_post(&deso_account, &comment_post_data).await.unwrap();
println!("Comment created with hash: {:?}", comment_transaction_json.post_entry_response.post_hash_hex);
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.