Class LogicSig

LogicSig implementation

LogicSig cannot sign transactions in all cases. Instead, use LogicSigAccount as a safe, general purpose signing mechanism. Since LogicSig does not track the provided signature's public key, LogicSig cannot sign transactions when delegated to a non-multisig account and the sender is not the delegating account.

Implements

Constructors

  • Parameters

    • program: Uint8Array
    • Optional programArgs: null | Uint8Array[]

    Returns LogicSig

Properties

args: Uint8Array[]
logic: Uint8Array
pqsig?: EncodedPQSig

The post-quantum delegation signature, if the delegating account is a post-quantum account. At most one of sig, msig, lmsig and pqsig may be set.

sig?: Uint8Array
encodingSchema: NamedMapSchema = ...

Methods

  • Compute hash of the logic sig program (that is the same as escrow account address) as string address

    Returns Address

    String representation of the address

  • Parameters

    • secretKey: Uint8Array

      Secret key to sign with

    Returns void

    Deprecated

    Use appendToMultisigWithSigner instead

    Appends a signature to multi signature

  • Appends an additional subsignature to this LogicSig's existing multisig delegation.

    Parameters

    Returns Promise<void>

    Remarks

    The multisig preimage is taken from the lmsig already on this LogicSig, so signWithSigner must have been called with an msig argument first. The signer must hold a key belonging to that multisig.

    A signature already collected from another member is never silently replaced: if the signer returns a different signature for a subsig that is already filled in, this throws instead.

    Throws

    If there is no multisig on this LogicSig, if the signer returns no signature, a signature for a key outside the multisig, or one that conflicts with a signature already collected

  • Removes every delegation signature from this LogicSig, so that exactly one of them can be set afterwards.

    Returns void

  • Get the encoding Schema for this object, used to prepare the encoding data for msgpack and JSON.

    Returns Schema

  • Parameters

    • secretKey: Uint8Array

      Secret key to sign with

    • Optional msig: MultisigMetadata

      Multisig account as {version, threshold, addrs}

    Returns void

    Deprecated

    Use signWithSigner instead

    Creates signature (if no msig provided) or multi signature otherwise

  • Signs arbitrary data for use with the ed25519verify opcode from within this LogicSig's program.

    Parameters

    • signer: ProgramDataSigner

      The signer to sign the data with

    • data: Uint8Array

      The data to sign

    Returns Promise<Uint8Array>

    A promise which resolves to the raw signature over the data

    Remarks

    This does not modify the LogicSig or delegate it; the LogicSig is only used for the address that domain-separates the signature. The program is responsible for verifying the returned signature against the signer's public key.

  • Parameters

    • secretKey: Uint8Array

    Returns Uint8Array

    Deprecated

    Use signWithSigner followed by .sig instead

  • Parameters

    Returns Uint8Array

    Deprecated

    Use signWithSigner followed by .sig instead

  • Signs this LogicSig for delegation using the given signer.

    Parameters

    Returns Promise<Address>

    The address the signer signed as. When msig is omitted this is the delegating account. When msig is given it is the individual subsigner, not the multisig, so the delegating account is multisigAddress(msig). Either way it is an authorizing address, which is not necessarily the address a signer sends transactions from.

    Remarks

    Re-signing an already-signed LogicSig is allowed, and replaces the previous delegation signature. At most one of sig, msig, lmsig and pqsig may be set, so any signature left over from an earlier call is cleared.

    Throws

    If the signer returns a signature of the wrong kind for the requested delegation, or an lmsig whose version, threshold or public keys do not match msig

  • Parameters

    Returns [sig: Uint8Array, index: number]

    Deprecated

    Use signWithSigner followed by .sig instead

  • Extract the encoding data for this object. This data, after being prepared by the encoding Schema, can be encoded to msgpack or JSON.

    Returns Map<string, unknown>

  • Parameters

    • publicKey: Uint8Array

      Verification key (derived from sender address or escrow address)

    Returns boolean

    Deprecated

    This function does not perform full verification and should not be fully trusted on its own. For example, it does not evaluate programs and does not have the ability to validate PQ signatures.

    Performs signature verification

Generated using TypeDoc