How can I get the transaction ID from a contract call using rust sdk?

Hi guys
Few times ago I answered on this question but it looks like not true because TxId cannot me like zero address

1 Like

There is currently an open issue to add the tx ID to FuelCallReponse: feat(contracts): add tx_id to FuelCallResponse by Br1ght0ne · Pull Request #734 · FuelLabs/fuels-rs · GitHub

Meanwhile, a possible workaround is to get the transaction that would be executed by the contract call, read it’s id, and execute the call via the provider:

// build the tx
let tx = contract_instance
    .methods() .some_contract_method().build_tx().await.unwrap(); 

// get the tx_id
let id = tx.id();

// send the tx
provider.send_transaction(&tx);

You can see another example below:

let call_handler = contract_instance_launched.methods().some_contract_method();
let tx = call_handler.build_tx().await.unwrap();

dbg!(tx.id());

let receipts = provider.send_transaction(&tx).await.unwrap();
let response = call_handler.get_response(receipts).unwrap();

Thank you a lot!!! :heart::heart::heart:

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.