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:
_10import * as sdk from "@onflow/sdk"_10_10sdk.validateSignableTransaction(signable)
Or import directly the specific function:
_10import { validateSignableTransaction } from "@onflow/sdk"_10_10validateSignableTransaction(signable)
Usage
_25import * 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_25const 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_25try {_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
_10interface Signable {_10 voucher: Voucher_10}
Returns
boolean