API Documentation


Bitcoin Asset

Examples | Type Definition

Beyond the standard Asset fields, additional information about the peer-to-peer network and blockchain is available for Bitcoin. This capability allows you to explore blocks, transactions, and addresses.

Generic asset related fields are available on the Asset type. All assets will have these properties. Additional Bitcoin specific fields are specified on the AssetBtc type.

You can access these fields by using the ... on AssetBtc inline fragment when returning an asset. Inline fragments are a way to specify additional properties on an object that can take on many forms, such as the Asset type.

You can read more information about inline fragments in the the GraphQL documentation.

A quick example shows how this can be used when accessing a single asset result for Bitcoin:

query singleAsset {
  asset(assetSymbol: "BTC") {
    assetName
    ... on AssetBtc {
      info {
        bestHeight
        bestBlockHash
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "info": {
        "bestHeight": 564038,
        "bestBlockHash": "00000000000000000029d93c23c5b44999ec62b384dba9c9ac728b56b50366de"
      }
    }
  }
}

Try me!

You can use this inline fragment for results that return any Asset. However, the additional fields are only included on the object when the asset is Bitcoin.

query multiAsset {
  assets(filter: { assetSymbol: { _in: ["BTC", "LTC"] } }) {
    assetName
    ... on AssetBtc {
      info {
        bestHeight
        bestBlockHash
      }
    }
  }
}
{
  "data": {
    "assets": [
      {
        "assetName": "Bitcoin",
        "info": {
          "bestHeight": 564038,
          "bestBlockHash": "00000000000000000029d93c23c5b44999ec62b384dba9c9ac728b56b50366de"
        }
      },
      {
        "assetName": "Litecoin"
      }
    ]
  }
}

Try me!

Notice that only the Bitcoin result includes the info object and associatd fields. Litecoin does not have the info field.

Examples

Bitcoin P2P info

Accesses fields about the current state of the P2P network when running a single asset query:

query bitcoin {
  asset(assetSymbol: "btc") {
    assetName
    ... on AssetBtc {
      info {
        bestHeight
        bestBlockHash
        blocks
        lastBlockUnix
        lastBlockDate
        mempoolSize
        difficulty
        sizeBytes
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "info": {
        "bestHeight": 564035,
        "bestBlockHash": "0000000000000000001f52e565680c38ad96b96aa9d296b0e61e484850308d39",
        "blocks": 564035,
        "lastBlockUnix": 1550763061,
        "lastBlockDate": "2019-02-21T15:31:01.592Z",
        "mempoolSize": 19746,
        "difficulty": "6061518831027.271",
        "sizeBytes": "233568909078"
      }
    }
  }
}

Try me!

Bitcoin block with first two transactions

Access fields about a block by querying the block height. You can also query by the block hash. You can return the number of transactions as well. By default, it returns the first 1000 transactions.

query bitcoin {
  asset(assetSymbol: "btc") {
    assetName
    ... on AssetBtc {
      block(height: 564035) {
        height
        hash
        prevHash
        nextHash
        merkleRoot
        difficulty
        sizeBytes
        time
        date
        bits
        nonce
        confirmations
        txCount
        txs(limit: 2) {
          txId
          valueIn
          valueOut
          fees
          vin {
            n
            value
            addresses
          }
          vout {
            n
            value
            spent
            addresses
          }
        }
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "block": {
        "height": 564035,
        "hash": "0000000000000000001f52e565680c38ad96b96aa9d296b0e61e484850308d39",
        "prevHash": "0000000000000000002dca26078ee9c88974291a379b21982494741446a301aa",
        "nextHash": "00000000000000000001d69e7ab89198bbe0300284fe70fac9a4250f57912626",
        "merkleRoot": "68d057e1e82316c4ea6f55305aa269ff1bc04b9192f27770793a33b99ee9efde",
        "difficulty": "6061518831027.271",
        "sizeBytes": "1284964",
        "time": 1550763048,
        "date": "2019-02-21T15:30:48.000Z",
        "bits": "172e6f88",
        "nonce": "3770545157",
        "confirmations": 3,
        "txCount": 3048,
        "txs": [
          {
            "txId": "e8416e671456833a27a214614e5d4c5aaf3c5f1260f360d88d9ad2d38a10290e",
            "valueIn": "0",
            "valueOut": "1277725661",
            "fees": "0",
            "vin": [
              {
                "n": 0,
                "value": "0",
                "addresses": []
              }
            ],
            "vout": [
              {
                "n": 0,
                "value": "1277725661",
                "spent": false,
                "addresses": ["18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX"]
              },
              {
                "n": 1,
                "value": "0",
                "spent": false,
                "addresses": [
                  "OP_RETURN aa21a9edbe3f4417cc89946aadf76157a1a377403693e049fad2e078680d54dc999529cf"
                ]
              }
            ]
          },
          {
            "txId": "9fbbe208291121cb7dd557219238407708b20424516c2e227532ada70965f843",
            "valueIn": "2569090886",
            "valueOut": "2569090444",
            "fees": "442",
            "vin": [
              {
                "n": 0,
                "value": "1310754078",
                "addresses": ["18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX"]
              },
              {
                "n": 1,
                "value": "1258336808",
                "addresses": ["18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX"]
              }
            ],
            "vout": [
              {
                "n": 0,
                "value": "559090886",
                "spent": false,
                "addresses": ["14L7pdRhN8sCxePrVmEeysvX1gMVej8oFG"]
              },
              {
                "n": 1,
                "value": "1000000000",
                "spent": false,
                "addresses": ["14QT8SKsJ13KokGDz6wHnpCRAsNGRJqjfp"]
              },
              {
                "n": 2,
                "value": "9999558",
                "spent": false,
                "addresses": ["1AmNARV5UCZgq1BW5vW5sihT3GaX4uRQp4"]
              },
              {
                "n": 3,
                "value": "1000000000",
                "spent": false,
                "addresses": ["1GwxsfTrDmhUxaQxkhjEP9pRMa8hcegh4g"]
              }
            ]
          }
        ]
      }
    }
  }
}

Try me!

Transaction details

View details about a transaction including detailed input and output information. The raw hex-encoded transaction is also returned.

query bitcoin {
  asset(assetSymbol: "btc") {
    assetName
    ... on AssetBtc {
      tx(txId: "9fbbe208291121cb7dd557219238407708b20424516c2e227532ada70965f843") {
        txId
        hash
        valueIn
        valueOut
        fees
        version
        sizeBytes
        vsizeBytes
        weight
        locktime
        blockhash
        confirmations
        blocktime
        blocktimeDate
        hex
        vin {
          n
          value
          coinbase
          txId
          vout
          sequence
          scriptSigAsm
          scriptSigHex
          addresses
        }
        vout {
          n
          value
          spent
          type
          scriptPubKeyAsm
          scriptPubKeyHex
          reqSigs
          addresses
        }
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "tx": {
        "txId": "9fbbe208291121cb7dd557219238407708b20424516c2e227532ada70965f843",
        "hash": "9fbbe208291121cb7dd557219238407708b20424516c2e227532ada70965f843",
        "valueIn": "2569090886",
        "valueOut": "2569090444",
        "fees": "442",
        "version": 2,
        "sizeBytes": 440,
        "vsizeBytes": 440,
        "weight": 1760,
        "locktime": 0,
        "blockhash": "0000000000000000001f52e565680c38ad96b96aa9d296b0e61e484850308d39",
        "confirmations": 3,
        "blocktime": 1550763048,
        "blocktimeDate": "2019-02-21T15:30:48.000Z",
        "hex": "02000000020610000749cf2e03959cb15d07386e6ce0066f44659944dfe1a3a6102033ac93000000006a47304402207f722cad4f9afe994477795a582f852331b793239752c7668372ad32ab628bf00220491c104334ba6b6c6a20b45e72b48d1b7b470f3ddedfb854f6fd337c2f755aec0121031277e88390c528ef8efac312d77d0566f756ed54046b8ba557a15b088b86e20bffffffff8b6766f559acd8de7f8d110d34c85f677ee3c0da888b1d5e4b98a30dace168c1000000006a47304402202902adc73fb44b1feeca38b081364e05f3ce8260feba6addc2b4b0870f0f381202207d517f348cec56a460cf1826f73c4ae7f054c7e1120d896582b7ccace2c68dfb0121031277e88390c528ef8efac312d77d0566f756ed54046b8ba557a15b088b86e20bffffffff04c60c5321000000001976a9142485f982e89499382f8bfe3824e818dceb1724d788ac00ca9a3b000000001976a9142557c155794d99cafa89b1efb7d20ce5f8d6084a88acc6949800000000001976a9146b1d1992d8475887005550c5d2547d31c61201b288ac00ca9a3b000000001976a914aeeefd52c974df1f19b942c85857613a46894eb188ac00000000",
        "vin": [
          {
            "n": 0,
            "value": "1310754078",
            "coinbase": null,
            "txId": "93ac332010a6a3e1df449965446f06e06c6e38075db19c95032ecf4907001006",
            "vout": 0,
            "sequence": "4294967295",
            "scriptSigAsm": "304402207f722cad4f9afe994477795a582f852331b793239752c7668372ad32ab628bf00220491c104334ba6b6c6a20b45e72b48d1b7b470f3ddedfb854f6fd337c2f755aec[ALL] 031277e88390c528ef8efac312d77d0566f756ed54046b8ba557a15b088b86e20b",
            "scriptSigHex": "47304402207f722cad4f9afe994477795a582f852331b793239752c7668372ad32ab628bf00220491c104334ba6b6c6a20b45e72b48d1b7b470f3ddedfb854f6fd337c2f755aec0121031277e88390c528ef8efac312d77d0566f756ed54046b8ba557a15b088b86e20b",
            "addresses": ["18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX"]
          },
          {
            "n": 1,
            "value": "1258336808",
            "coinbase": null,
            "txId": "c168e1ac0da3984b5e1d8b88dac0e37e675fc8340d118d7fded8ac59f566678b",
            "vout": 0,
            "sequence": "4294967295",
            "scriptSigAsm": "304402202902adc73fb44b1feeca38b081364e05f3ce8260feba6addc2b4b0870f0f381202207d517f348cec56a460cf1826f73c4ae7f054c7e1120d896582b7ccace2c68dfb[ALL] 031277e88390c528ef8efac312d77d0566f756ed54046b8ba557a15b088b86e20b",
            "scriptSigHex": "47304402202902adc73fb44b1feeca38b081364e05f3ce8260feba6addc2b4b0870f0f381202207d517f348cec56a460cf1826f73c4ae7f054c7e1120d896582b7ccace2c68dfb0121031277e88390c528ef8efac312d77d0566f756ed54046b8ba557a15b088b86e20b",
            "addresses": ["18cBEMRxXHqzWWCxZNtU91F5sbUNKhL5PX"]
          }
        ],
        "vout": [
          {
            "n": 0,
            "value": "559090886",
            "spent": null,
            "type": "pubkeyhash",
            "scriptPubKeyAsm": "OP_DUP OP_HASH160 2485f982e89499382f8bfe3824e818dceb1724d7 OP_EQUALVERIFY OP_CHECKSIG",
            "scriptPubKeyHex": "76a9142485f982e89499382f8bfe3824e818dceb1724d788ac",
            "reqSigs": 1,
            "addresses": ["14L7pdRhN8sCxePrVmEeysvX1gMVej8oFG"]
          },
          {
            "n": 1,
            "value": "1000000000",
            "spent": null,
            "type": "pubkeyhash",
            "scriptPubKeyAsm": "OP_DUP OP_HASH160 2557c155794d99cafa89b1efb7d20ce5f8d6084a OP_EQUALVERIFY OP_CHECKSIG",
            "scriptPubKeyHex": "76a9142557c155794d99cafa89b1efb7d20ce5f8d6084a88ac",
            "reqSigs": 1,
            "addresses": ["14QT8SKsJ13KokGDz6wHnpCRAsNGRJqjfp"]
          },
          {
            "n": 2,
            "value": "9999558",
            "spent": null,
            "type": "pubkeyhash",
            "scriptPubKeyAsm": "OP_DUP OP_HASH160 6b1d1992d8475887005550c5d2547d31c61201b2 OP_EQUALVERIFY OP_CHECKSIG",
            "scriptPubKeyHex": "76a9146b1d1992d8475887005550c5d2547d31c61201b288ac",
            "reqSigs": 1,
            "addresses": ["1AmNARV5UCZgq1BW5vW5sihT3GaX4uRQp4"]
          },
          {
            "n": 3,
            "value": "1000000000",
            "spent": null,
            "type": "pubkeyhash",
            "scriptPubKeyAsm": "OP_DUP OP_HASH160 aeeefd52c974df1f19b942c85857613a46894eb1 OP_EQUALVERIFY OP_CHECKSIG",
            "scriptPubKeyHex": "76a914aeeefd52c974df1f19b942c85857613a46894eb188ac",
            "reqSigs": 1,
            "addresses": ["1GwxsfTrDmhUxaQxkhjEP9pRMa8hcegh4g"]
          }
        ]
      }
    }
  }
}

Try me!

Address details

View summary information about an address and return a list of transaction ids. By default the first 1000 txids are returned.

query bitcoin {
  asset(assetSymbol: "btc") {
    assetName
    ... on AssetBtc {
      address(address: "14QT8SKsJ13KokGDz6wHnpCRAsNGRJqjfp") {
        address
        balance
        totalReceived
        totalSent
        unconfirmedBalance
        unconfirmedTxCount
        txCount
        txIds(limit: 5)
      }
    }
  }
}
{
  "data": {
    "asset": {
      "assetName": "Bitcoin",
      "address": {
        "address": "14QT8SKsJ13KokGDz6wHnpCRAsNGRJqjfp",
        "balance": "1000000000",
        "totalReceived": "35675209293",
        "totalSent": "34675209293",
        "unconfirmedBalance": "0",
        "unconfirmedTxCount": 0,
        "txCount": 127,
        "txIds": [
          "9fbbe208291121cb7dd557219238407708b20424516c2e227532ada70965f843",
          "d6575e6f4699ae95e06c18f05b4a219dddc04c30868cfc522fc09063123ec857",
          "d60f62045f868f624a4c624fd2c2539337c2e5828ceef9fbca744697a05330ce",
          "ac314adce92e4a4edeb866657d248ab1598db272843bdf0ba19c7109f39b6399",
          "f915c42e9236e55e7f8c712ede5c670e8ef2fb6ed5a14b5f4569fa144ca883b2"
        ]
      }
    }
  }
}

Try me!