FrameSignature.from
Coerces a value into a FrameSignature.FrameSignature.
Accepts arbitrary signature bytes or a signature entry. Protocol signatures accept structured objects or Signature.toHex bytes. P-256 entries still require a public key. Omitted scheme and payload default to 'arbitrary' and '0x', respectively. An empty payload selects the canonical transaction signing hash; an explicit payload must be a nonzero 32-byte digest.
Imports
import { FrameSignature } from 'ox'Examples
From Hex
Wrap arbitrary witness bytes for contract-defined verification.
import { FrameSignature } from 'ox'
const entry = FrameSignature.from('0xaabb')
{ payload: '0x', scheme: 'arbitrary', signature: '0xaabb' }Secp256k1
Wrap a signature over an explicit digest, retaining the same payload in the entry.
import { FrameSignature, Hash, Secp256k1 } from 'ox'
const payload = Hash.keccak256('0xdeadbeef')
const privateKey = Secp256k1.randomPrivateKey()
const signature = Secp256k1.sign({ payload, privateKey })
const entry = FrameSignature.from({
payload,
scheme: 'secp256k1',
signature
})P256
Include the public key with a P-256 signature over an explicit digest.
import { FrameSignature, Hash, P256 } from 'ox'
const { privateKey, publicKey } = P256.createKeyPair()
const payload = Hash.keccak256('0xdeadbeef')
const signature = P256.sign({ payload, privateKey })
const entry = FrameSignature.from({
payload,
publicKey,
scheme: 'p256',
signature
})Unsigned Entries
Omit the signature to prepare a protocol entry before signing the transaction.
import { FrameSignature } from 'ox'
const entry = FrameSignature.from({ scheme: 'secp256k1' })
{ payload: '0x', scheme: 'secp256k1' }Definition
function from<entry>(
entry: entry | from.Input,
): from.ReturnType<entry>Source: src/core/FrameSignature.ts
Parameters
entry
- Type:
entry | from.Input
Arbitrary signature bytes or a structured signature entry.
Return Type
The validated entry, preserving supplied signature and scheme types.
from.ReturnType<entry>

