encodeTransactionPayload
Encodes a transaction payload for signing.
This function takes a transaction object and encodes it into a format suitable for signing. The encoded payload contains all the transaction details except for the signatures.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.encodeTransactionPayload(tx)
Or import directly the specific function:
_10import { encodeTransactionPayload } from "@onflow/sdk"_10_10encodeTransactionPayload(tx)
Usage
_23import * as fcl from "@onflow/fcl";_23import { encodeTransactionPayload } from "@onflow/sdk"_23_23// Build a transaction_23const transaction = await fcl.build([_23  fcl.transaction`_23    transaction(amount: UFix64) {_23      prepare(account: AuthAccount) {_23        log("Transferring: ".concat(amount.toString()))_23      }_23    }_23  `,_23  fcl.args([fcl.arg("10.0", fcl.t.UFix64)]),_23  fcl.proposer(proposerAuthz),_23  fcl.payer(payerAuthz),_23  fcl.authorizations([authorizerAuthz]),_23  fcl.limit(100)_23]);_23_23// Encode the transaction payload for signing_23const encodedPayload = encodeTransactionPayload(transaction);_23console.log("Encoded payload:", encodedPayload);_23// Returns a hex string like "f90145b90140..."
Parameters
tx
- Type: Transaction
- Description: The transaction object to encode
Returns
string
A hex-encoded string representing the transaction payload