bitcoinjs-lib SDK

website·Indexed 33 days ago

https://docs.scrypt.io

SDK documentation for bitcoinjs-lib v0.2.9-beta.16, featuring technical references for classes like TxUtils and TxProof, interfaces such as IExtPsbt and ChainProvider, and utility functions for cryptographic operations including sha256, ripemd160, and pubKey2Addr.

Tokens
185.6K
Snippets
1.5K
Records
1.8K
Agent score
65%

What's inside bitcoinjs-lib

  1. Overview of the Provider class

    The Provider class is an abstraction for non-account-based operations on a blockchain. It is primarily used for interacting with the blockchain and is generally not involved in signing transactions or data. It extends EventEmitter, allowing it to handle event-driven communication.
  2. Overview of sCrypt Providers

    A Provider in sCrypt is an abstraction of a Bitcoin node that allows an application to communicate with the Bitcoin network. sCrypt includes several built-in providers:

    • DummyProvider: A mockup for local testing; it cannot send transactions.
    • DefaultProvider: A robust provider suitable for both testnet and mainnet, recommended for most development and production use cases.
  3. Overview of the OpCode class

    The OpCode class defines the set of Script words (opcodes, commands, or functions) used in BTC Script. It is primarily used within smart contract scripts to perform on-chain operations.
  4. Introduction to sCrypt

    sCrypt is an embedded Domain Specific Language (eDSL) based on TypeScript designed for writing smart contracts on the Bitcoin blockchain. Because it is an eDSL, sCrypt is a strict subset of TypeScript; all sCrypt code is valid TypeScript, though the reverse is not necessarily true. sCrypt allows developers to write high-level logic that is compiled into Bitcoin Script (assembly-like bytecode), which serves as the locking script for Bitcoin transactions.
  5. Overview of Blockchain Oracle Architecture with Rabin Signatures

    A blockchain oracle acts as a bridge providing external data to a network. To ensure data integrity, the oracle signs data off-chain using a Rabin signature. Rabin signatures are preferred over ECDSA for this use case because signature generation is computationally expensive (done off-chain by the oracle), while verification is computationally cheap (done on-chain by the smart contract). Standard checkSig opcodes are not used because they only verify transaction data, whereas Rabin signatures allow verification of arbitrary external data.
  6. Introduction to sCrypt

    sCrypt is an embedded Domain Specific Language (eDSL) based on TypeScript used for writing smart contracts on Bitcoin. Because it is an eDSL, sCrypt is a strict subset of TypeScript; all sCrypt code is valid TypeScript. It is designed to provide type safety and a familiar development experience for creating safe smart contracts. sCrypt compiles high-level code into Bitcoin Script, which is then used as locking scripts in Bitcoin transactions.
  7. Overview of TxUtils class

    The TxUtils class is a library used for parsing and constructing Bitcoin transactions within smart contracts. It extends SmartContractLib and provides a set of static methods to build serialized transaction outputs.
  8. Overview of GorillapoolProvider

    The GorillapoolProvider is a provider class used to interact with the BSV blockchain via the gorillapool API. It inherits from the base Provider class and implements standard blockchain interaction methods.
    const provider = new GorillapoolProvider();
  9. Overview of the Psbt class

    The Psbt class is used to parse and generate PSBT binaries based on BIP174. It fulfills six primary roles in the transaction lifecycle:

    1. Creator: Initializes a new PSBT using new Psbt().
    2. Updater: Adds or modifies inputs and outputs using addInput, addInputs, addOutput, addOutputs, updateGlobal, updateInput, and updateOutput.
    3. Signer: Signs inputs using signAllInputs, signAllInputsAsync, signInput, or signInputAsync. Async methods allow for external signers like hardware wallets via a SignerAsync object.
    4. Combiner: Merges multiple PSBTs using psbt.combine(psbt2, psbt3, ...). The calling PSBT takes precedence in conflicts. All combined PSBTs must have identical sequences, versions, and locktimes.
    5. Input Finalizer: Constructs scriptSigs and witnesses. It is recommended to call validateSignaturesOfAllInputs() before finalizeAllInputs(). Finalizing deletes unnecessary data from the inputs.
    6. Transaction Extractor: Performs final checks (e.g., verifying the fee rate does not exceed maximumFeeRate) before returning a standard Transaction object.
  10. Overview of ContextUtils class

    The ContextUtils class is a library used within sCrypt smart contracts to verify preimages and validate transaction context data. It extends SmartContractLib and is primarily used for on-chain verification of transaction inputs and signatures.
  11. Overview of the bitcoinjs-lib address namespace

    The address namespace in bitcoinjs-lib provides utilities for encoding and decoding Bitcoin addresses. It supports multiple network environments including Bitcoin mainnet, testnet, and regtest. Supported address types include P2PKH, P2SH, P2WPKH, P2WSH, and P2TR. The namespace provides functions to convert between addresses and output scripts, as well as support for Base58 and Bech32 encoding formats.