Skip to main content

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:


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

Or import directly the specific function:


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

Usage


_23
import * as fcl from "@onflow/fcl";
_23
import { encodeTransactionPayload } from "@onflow/sdk"
_23
_23
// Build a transaction
_23
const 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
_23
const encodedPayload = encodeTransactionPayload(transaction);
_23
console.log("Encoded payload:", encodedPayload);
_23
// Returns a hex string like "f90145b90140..."

Parameters

tx

  • Type: Transaction
  • Description: The transaction object to encode

Returns

string


Rate this page