Skip to main content

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:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.encodeTransactionEnvelope(tx)

Or import directly the specific function:


_10
import { encodeTransactionEnvelope } from "@onflow/sdk"
_10
_10
encodeTransactionEnvelope(tx)

Usage


_26
import * as fcl from "@onflow/fcl";
_26
import { encodeTransactionEnvelope } from "@onflow/sdk"
_26
_26
// Assuming you have a fully built and signed transaction
_26
const 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
_26
const encodedEnvelope = encodeTransactionEnvelope(signedTransaction);
_26
console.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


Rate this page