Created
October 27, 2021 21:16
-
-
Save gregsantos/ef83e9bafbf7454b2bb961f815cc7fef to your computer and use it in GitHub Desktop.
get transaction hash before send
This file contains hidden or 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
| let txIdCalculated = null | |
| const getTxHash = async () => { | |
| const txIdFromChain = await sdk.decode( | |
| await sdk.send( | |
| await sdk.resolve( | |
| await sdk.build([ | |
| sdk.transaction`transaction(msg: String) { prepare(acct: AuthAccount) {} execute { log(msg) } }`, | |
| sdk.args([sdk.arg("Hello, Flow!", t.String)]), | |
| sdk.payer(fcl.currentUser().authorization), | |
| sdk.proposer(fcl.currentUser().authorization), | |
| sdk.authorizations([fcl.currentUser().authorization]), | |
| sdk.preSendCheck(async voucher => { | |
| txIdCalculated = sdk.voucherToTxId(voucher) | |
| }), | |
| ]) | |
| ), | |
| {node: "https://access-testnet.onflow.org"} | |
| ) | |
| ) | |
| console.log("TX ID", txIdFromChain) | |
| console.log("Pre calculated TxID", txIdCalculated) | |
| invariant(txIdCalculated === txIdFromChain, "Uh oh, didn't work") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment