Public docs
WebsiteTAAL PlatformWhatsOnChain
  • Welcome
  • Introduction
    • Get an API Key
  • Core Products
    • WhatsOnChain
      • Health
      • Chain Info
      • Block
      • Transaction
      • Mempool
      • (Un)Spent Transaction Outputs
      • Address
      • Script
      • Exchange Rate
      • Search
      • WoC Widgets
      • WoC Plugins
      • On-Chain Data
      • Output Tags
      • Stats
      • WebSockets
        • WoC Sockets V1 (Deprecated)
        • WoC Sockets V2 (Beta)
      • Tokens
        • 1Sat Ordinals (Beta)
        • BSV-21 (Beta)
        • STAS Tokens (Beta)
      • Change Log
      • Community Libraries
    • Transaction Processing
      • ARC Endpoints
      • Transaction format and fee rate
    • TAAL Wallet
      • Introduction
      • Architecture
      • Terminology
      • UI Elements
      • Tutorial
    • 1Sat Ordinals tokens API
      • Introduction
      • Terminology
      • Flow Diagram
      • Basic Tutorial - Node
      • Basic Tutorial - Postman
      • API
  • Resources
    • FAQ
    • Support
    • Glossary
    • Acronyms and Abbreviations
Powered by GitBook
On this page
  • Fee rate
  • Transaction format

Was this helpful?

Export as PDF
  1. Core Products
  2. Transaction Processing

Transaction format and fee rate

PreviousARC EndpointsNextTAAL Wallet

Last updated 1 year ago

Was this helpful?

Fee rate

The current standard fee rate which applies to all transactions submitted to any of the TAAL transaction processing APIs is: 1 sat/kb

The minimum fee for any transaction is 1 sat.

The fee required is rounded depending on size of the transaction. The following list exemplifies the logic:

  • Transactions with 1.4999... kb > size > 0.0 kb => min absolute fee required = 1 sat.

  • Transactions with 2.4999... kb > size > 1.5 kb => min absolute fee required = 2 sat

  • Transactions with 3.4999... kb > size > 2.5 kb => min absolute fee required = 3 sat

  • ...

Transaction format

The format of transaction is bound to the standard of BSV transactions as described .

There is a number of libraries which allow to build BSV transactions. Here is a short list:

Javascript example using version 1 of bsv.js and request modules

  1. Create a new Node.js project:

    mkdir example
    cd example
    npm init -y
    npm install bsv@1
    npm install request
  2. Save the following code to a main.js in your example folder:

    const fs = require('fs')
    const bsv = require('bsv')
    
    // Random key produced each time...
    const newKey = bsv.PrivateKey()
    
    console.log(`Private key:     ${newKey.toString()}`)
    console.log(`Mainnet address: ${newKey.toAddress('mainnet').toString()}`)
    
    console.log(`
    1. Create a funding transaction by sending 1000 satoshis (0.00001 BSV) to ${newKey.toAddress('mainnet').toString()}.
    
    2. Add your Taal apiKey, and funding transaction txid and vout to 'generated.js'.
    
    3. Execute the generated code:
    
      node generated.js
    
    `)
    
    
    fs.writeFileSync('generated.js', `
    const bsv = require('bsv')
    var request = require('request')
    
    const privKey = bsv.PrivateKey('${newKey}')
    
    const apiKey = ""        // Add Taal mainnet API Key
    const fundingTxid = ""   // Add the funding transaction txid
    const fundingVout = -1   // Replace with funding transaction vout
    const returnAddress = "" // The address to return the 1000 satoshis (less fees)
    
    if (apiKey === "" || fundingTxid === "" || fundingVout === -1 || returnAddress === "") {
      console.log('This generated file needs an apiKey, a fundingTxid, a fundingVout and a returnAddress')
      process.exit(1)
    }
    
    const utxo1 = {
      txId: fundingTxid,
      outputIndex: fundingVout,
      address: privKey.toAddress('mainnet').toString(),
      script: bsv.Script.buildPublicKeyHashOut(privKey.publicKey).toHex(),
      satoshis: 1000
    }
    
    const tx1 = bsv.Transaction()
      .from(utxo1)
      .to(privKey.toAddress('mainnet').toString(), 800)
      .change(returnAddress)
      .sign(privKey)
    
    const utxo2 = {
      txId: tx1.hash,
      outputIndex: 0,
      address: privKey.toAddress('mainnet').toString(),
      script: bsv.Script.buildPublicKeyHashOut(privKey.publicKey).toHex(),
      satoshis: 800
    }
    
    const tx2 = bsv.Transaction()
      .from(utxo2)
      .change(returnAddress)
      .sign(privKey)
      
    
    const txBuffer = Buffer.concat([
      tx1.toBuffer(),
      tx2.toBuffer()
    ])
    
    // Send the transaction to Taal API...
    request.post({
      url: 'https://api.taal.com/api/v1/batchBroadcast',
      headers: {
        'Authorization': apiKey,
        'Content-Type': 'application/octet-stream'
      },
      body: txBuffer
    }, function(error, response, body) {
      console.log(error, response.statusCode, body)
    })
    `)
  3. Execute the code and follow the onscreen instructions:

    node main.js   
here
https://www.npmjs.com/package/bsv
https://github.com/libsv/go-bt