Skip to content

Commit

Permalink
Add example of how to submit a transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
marcospb19 committed Oct 12, 2021
1 parent e109641 commit fd0d1a3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/submit_transaction.rs
@@ -0,0 +1,21 @@
use blockfrost::{env, BlockFrostApi, Settings};

fn build_api() -> blockfrost::Result<BlockFrostApi> {
let project_id = env::load_project_id()?.expect("BLOCKFROST_PROJECT_ID not found.");
let api = BlockFrostApi::new(project_id, Settings::new());
Ok(api)
}

#[tokio::main]
async fn main() -> blockfrost::Result<()> {
let api = build_api()?;

// Should contain the correct cbor contents
let transaction_data = vec![0; 1024]; // Just an example (will fail)
let transaction_hash = api.transactions_submit(transaction_data).await?;

// At this point, you should probably save the transaction_hash
println!("{}", transaction_hash);

Ok(())
}

0 comments on commit fd0d1a3

Please sign in to comment.