Type alias Output<Bytecode, ByteStringRepresentation, NumericRepresentation>

Output<Bytecode, ByteStringRepresentation, NumericRepresentation>: {
    lockingBytecode: Bytecode;
    token?: {
        amount: NumericRepresentation;
        category: ByteStringRepresentation;
        nft?: {
            capability: `${NonFungibleTokenCapability}`;
            commitment: ByteStringRepresentation;
        };
    };
    valueSatoshis: NumericRepresentation;
}

Data type representing a Transaction Output.

Type Parameters

  • Bytecode = Uint8Array

    the type of lockingBytecode - this can be configured to allow for defining compilation directives.

  • ByteStringRepresentation = Uint8Array

    the type used to represent strings of bytes (in Output.token.category and Output.token.commitment)

    • this allows for JSON-compatible types to be used rather than the default Uint8Array.
  • NumericRepresentation = bigint

Type declaration

  • lockingBytecode: Bytecode

    The bytecode used to encumber this transaction output. To spend the output, unlocking bytecode must be included in a transaction input that – when evaluated before the locking bytecode – completes in a valid state.

    A.K.A. scriptPubKey or "locking script"

  • Optional token?: {
        amount: NumericRepresentation;
        category: ByteStringRepresentation;
        nft?: {
            capability: `${NonFungibleTokenCapability}`;
            commitment: ByteStringRepresentation;
        };
    }

    The CashToken contents of this output. This property is only defined if the output contains one or more tokens. For details, see CHIP-2022-02-CashTokens.

    • amount: NumericRepresentation

      The number of fungible tokens (of category) held in this output.

      Because Number.MAX_SAFE_INTEGER (9007199254740991) is less than the maximum token amount (9223372036854775807), this value is encoded as a bigint.

    • category: ByteStringRepresentation

      The 32-byte ID of the token category to which the token(s) in this output belong in big-endian byte order. This is the byte order typically seen in block explorers and user interfaces (as opposed to little-endian byte order, which is used in standard P2P network messages).

    • Optional nft?: {
          capability: `${NonFungibleTokenCapability}`;
          commitment: ByteStringRepresentation;
      }

      If present, the non-fungible token (NFT) held by this output. If the output does not include a non-fungible token, undefined.

  • valueSatoshis: NumericRepresentation

    The value of the output in satoshis, the smallest unit of bitcoin.

    There are 100 satoshis in a bit, and 100,000,000 satoshis in a bitcoin.

    This value could be defined using a number, as Number.MAX_SAFE_INTEGER (9007199254740991) is about 4 times larger than the maximum number of satoshis that should ever exist. I.e. even if all satoshis were consolidated into a single output, the transaction spending this output could still be defined with a numeric valueSatoshis.

    However, because the encoded output format for version 1 and 2 transactions (used in both transaction encoding and signing serialization) uses a 64-bit unsigned, little-endian integer to encode valueSatoshis, this property is encoded as a bigint, allowing it to cover the full possible range.

    This is useful for encoding values using schemes for fractional satoshis (for which no finalized specification yet exists) or for encoding intentionally excessive values. For example, excessiveSatoshis (0xffffffffffffffff - the maximum uint64 value) is a clearly impossible valueSatoshis value for version 1 and 2 transactions. As such, this value can safely be used by transaction signing and verification implementations to ensure that an otherwise properly-signed transaction can never be included in the blockchain, e.g. for testing, transaction size estimation, or off-chain Bitauth signatures.

    To convert this value to and from a Uint8Array use valueSatoshisToBin and binToValueSatoshis, respectively.

Generated using TypeDoc