Send Transaction with Blocto wallet through Flow Client Library (FCL)
Before sending a transaction, user needs to connect to Blocto wallet first.
Step 1 - Send transaction
import*as fcl from"@blocto/fcl";constSIMPLE_TRANSACTION=`\transaction { execute { log("Hello World!!") }}`;consttransactionId=awaitfcl.mutate({ cadence:SIMPLE_TRANSACTION, proposer:fcl.currentUser, payer:fcl.currentUser, limit:50,});// The transactions status and events after being sealedconsttransaction=awaitfcl.tx(transactionId).onceSealed();
Step 2 - Authorizing a transaction
import*as fcl from"@blocto/fcl";consttransactionId=awaitfcl.mutate({ cadence:` transaction { prepare(acct: AuthAccount) { log("Hello from prepare") } execute { log("Hello from execute") } } `, proposer:fcl.currentUser, payer:fcl.currentUser, authorizations: [fcl.currentUser], limit:50,});consttransaction=awaitfcl.tx(transactionId).onceSealed();console.log(transaction); // The transactions status and events after being sealed