encodeMessageFromSignable
Encodes a message from a signable object for a specific signer address.
This function determines whether the signer should sign the transaction payload or envelope based on their role in the transaction (authorizer, proposer, or payer), then encodes the appropriate message for signing.
Payload signers include authorizers and proposers (but not payers) Envelope signers include only payers
The encoded message is what gets signed by the account's private key to create the transaction signature.
Import
You can import the entire package and access the function:
_10import * as sdk from "@onflow/sdk"_10_10sdk.encodeMessageFromSignable(signable, signerAddress)
Or import directly the specific function:
_10import { encodeMessageFromSignable } from "@onflow/sdk"_10_10encodeMessageFromSignable(signable, signerAddress)
Usage
_25import * as fcl from "@onflow/fcl";_25_25// This function is typically used internally by authorization functions_25// when implementing custom wallet connectors or signing flows_25_25const signable = {_25 voucher: {_25 cadence: "transaction { prepare(acct: AuthAccount) {} }",_25 authorizers: ["0x01"],_25 proposalKey: { address: "0x01", keyId: 0, sequenceNum: 42 },_25 payer: "0x02",_25 refBlock: "a1b2c3",_25 computeLimit: 100,_25 arguments: [],_25 payloadSigs: []_25 }_25};_25_25// For an authorizer (payload signer)_25const authorizerMessage = fcl.encodeMessageFromSignable(signable, "0x01");_25console.log("Authorizer signs:", authorizerMessage);_25_25// For a payer (envelope signer)_25const payerMessage = fcl.encodeMessageFromSignable(signable, "0x02");_25console.log("Payer signs:", payerMessage);
Parameters
signable
- Type:
Signable
- Description: The signable object containing transaction data and voucher
_10interface Signable {_10 voucher: Voucher_10}
signerAddress
- Type:
string
- Description: The address of the signer to encode the message for
Returns
string