JavaScript access to the blockchain

livetransactions service

This page describes the functions made available in the livetransaction service.

FloweeJS ships with several services, each of which have specialized functions that make it easy to access the information. The live-transactions service contains functions that can be used to interact with not yet confirmed transactions.

Where the name Flowee is used, this is the variable which results from a call similar to:

const FloweeServices = require('floweejs');
var Flowee = new FloweeServices();`

Functions

  • Flowee.getLiveTransaction(txid)
    Get Live transaction can return not yet mined transactions by txid
       try {
          let answer = await Flowee.getLiveTransaction(txid);
       } catch (e) {
          console.log(e);
       }
    Please be aware that when the txid is not available it will reject the promise. Which is why you likely want to use the try/catch or similar solution.
    The return type is a byte buffer.
  • Flowee.isUnspent(obj)
    Fetch the UTXO status of a certain output.
    This returns a simple true or false to state if the output is unspent. If the transaction is not found, your promise will fail.
        let answer = await flowee.isUnspent({
            txid: "82f8dc85e292696c99323b397dc3027d7f4e074f5b5e2b81dc4d5e7f666a9127",
            outIndex: 0
          });
    or:
        let answer = await flowee.isUnspent({
             blockHeight: 500000,
             offsetInBlock: 29710,
             outIndex: 0
           });
    The return type is a byte buffer.
  • Flowee.getUnspentOutput(param)
    Fetch the UTXO status of a certain output. This returns an object like:
    {
      unspent: true,
      blockHeight: 645736,
      offsetInBlock: 87073,
      outputIndex: 0,
      amount: 11504,
      outputScript: Uint8Array(25) [
        118, 169,  20, 192,  85,   8, 224,
         42, 205,  62,  52, 105, 131, 102,
         11, 149, 159, 183, 143,  57, 145,
         62,  22, 136, 172
      ]
    }
    Please check isUnspent() for similar functionality that is much cheaper to run if all you need is the unspent status.
        let answer = await Flowee.getUnspentOutput({
            txid: "82f8dc85e292696c99323b397dc3027d7f4e074f5b5e2b81dc4d5e7f666a9127",
            outIndex: 0
          });
    or:
        let answer = await Flowee.getUnspentOutput({
             blockHeight: 500000,
             offsetInBlock: 29710,
             outIndex: 0
           });