Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example of how to submit a transaction
- Loading branch information
1 parent
e109641
commit fd0d1a3
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(()) | ||
} |