use algonaut::algod::v2::Algod; use algonaut::core::{MicroAlgos, ToMsgPack}; use algonaut::transaction::account::Account; use algonaut::transaction::{Pay, TxnBuilder}; use dotenv::dotenv; use std::env; use std::error::Error; use std::fs::File; use std::io::Write; #[tokio::main] async fn main() -> Result<(), Box> { // load variables in .env dotenv().ok(); let algod = Algod::new(&env::var("ALGOD_URL")?, &env::var("ALGOD_TOKEN")?)?; let account = Account::from_mnemonic("auction inquiry lava second expand liberty glass involve ginger illness length room item discover ahead table doctor term tackle cement bonus profit right above catch")?; let params = algod.suggested_transaction_params().await?; let t = TxnBuilder::with( ¶ms, Pay::new( account.address(), "4MYUHDWHWXAKA5KA7U5PEN646VYUANBFXVJNONBK3TIMHEMWMD4UBOJBI4".parse()?, MicroAlgos(123_456), ) .build(), ) .build()?; // sign the transaction let signed_transaction = account.sign_transaction(t)?; let bytes = signed_transaction.to_msg_pack()?; let filename = "./signed.tx"; let mut f = File::create(filename)?; f.write_all(&bytes)?; println!("Saved signed transaction to file: {}", filename); Ok(()) }