Skip to main content

validateSignableTransaction

Validates that a signable transaction is properly formed and contains the expected message.

This function verifies that the message in a signable object matches the expected encoded message based on the signer's role (payer or non-payer). It ensures the integrity of the signing process by confirming that the message to be signed corresponds correctly to the transaction data.

For payers: Validates against the transaction envelope encoding For non-payers (proposers/authorizers): Validates against the transaction payload encoding

Import

You can import the entire package and access the function:


_10
import * as sdk from "@onflow/sdk"
_10
_10
sdk.validateSignableTransaction(signable)

Or import directly the specific function:


_10
import { validateSignableTransaction } from "@onflow/sdk"
_10
_10
validateSignableTransaction(signable)

Usage


_25
import * as fcl from "@onflow/fcl";
_25
_25
// This function is typically used internally by wallet connectors
_25
// and authorization functions to ensure transaction integrity
_25
_25
const signable = {
_25
roles: { payer: true, proposer: false, authorizer: false },
_25
voucher: {
_25
cadence: "transaction { prepare(acct: AuthAccount) {} }",
_25
proposalKey: { address: "0x01", keyId: 0, sequenceNum: 42 },
_25
payer: "0x02",
_25
authorizers: ["0x01"],
_25
// ... other voucher data
_25
},
_25
message: "encoded_transaction_envelope_here"
_25
};
_25
_25
try {
_25
const isValid = fcl.validateSignableTransaction(signable);
_25
console.log("Signable is valid:", isValid);
_25
// Proceed with signing
_25
} catch (error) {
_25
console.error("Invalid signable:", error.message);
_25
// Handle validation failure
_25
}

Parameters

signable

  • Type: Signable
  • Description: The signable object to validate

_10
interface Signable {
_10
voucher: Voucher
_10
}

Returns

boolean


Rate this page