encodeTransactionEnvelope
Encodes a complete transaction envelope including payload and signatures.
This function encodes the full transaction including both the payload and all signatures. This is the final step before submitting a transaction to the Flow network.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.encodeTransactionEnvelope(tx)
Or import directly the specific function:
_10import { encodeTransactionEnvelope } from "@onflow/sdk"_10_10encodeTransactionEnvelope(tx)
Usage
_26import * as fcl from "@onflow/fcl";_26import { encodeTransactionEnvelope } from "@onflow/sdk"_26_26// Assuming you have a fully built and signed transaction_26const signedTransaction = await fcl.build([_26 fcl.transaction`_26 transaction {_26 prepare(account: AuthAccount) {_26 log("Hello, Flow!")_26 }_26 }_26 `,_26 fcl.proposer(authz),_26 fcl.payer(authz),_26 fcl.authorizations([authz]),_26 fcl.limit(100)_26]);_26_26// Add signatures to the transaction (this is usually done automatically)_26// signedTransaction.payloadSigs = [...];_26// signedTransaction.envelopeSigs = [...];_26_26// Encode the complete transaction envelope_26const encodedEnvelope = encodeTransactionEnvelope(signedTransaction);_26console.log("Encoded envelope:", encodedEnvelope);_26// Returns a hex string ready for network submission
Parameters
tx
- Type:
Transaction
- Description: The transaction object to encode
Returns
string