0.0.6 • Published 6 years ago

bitcore-specialops-btx v0.0.6

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Special Ops

A BitCore blockchain metadata web service for Bitcore Node.

OP_RETURN is a script opcode used to mark a transaction output as invalid. It can be used to save metadata on the blockchain.

It is used for Proof of Existence, Digital Arts, Assets, etc.

In order to find an OP_RETURN code quickly, specialops is the best choice.

Prerequisites

Usage

Follow this guide to install and run a full Bitcore node.

Assuming the created Bitcore node is called mynode and resides in your home directory:

cd ~/mynode
npm install --save bitcore-specialops-btx

Add specialops as a dependency in ~/mynode/bitcore-node.json:

{
  "version": "5.0.0-beta.44",
  "network": "testnet",
  "port": 3001,
  "services": [
    "address",
    "block",
    "db",
    "fee",
    "header",
    "mempool",
    "p2p",
    "timestamp",
    "transaction",
    "web",
    "insight-api-btx",
    "bitcore-specialops-btx"
  ],
  "datadir": "./data"
}

Start bitcore-node-btx, then you can access the service with http://localhost:3001/opcodes.

API HTTP Endpoints

We can support btx mainnet, testnet3 and regtest

Metadata

Get the transactions that contain the metadata.

ResourceMethodRequest ObjectReturn Object
/metadata/:hex[?limit=1]GETOP_RETURN dataMetadata Object

NOTE:

Range of limit: 1, 100, default: 10

  • Usage:
curl http://localhost:3001/opcodes/metadata/444f4350524f4f465efa245c88af3bc0bf9e4392976cedafd9a0de8d3f737ba0f48231b0f9262110
curl http://localhost:3001/opcodes/metadata/444f4350524f4f465efa245c88af3bc0bf9e4392976cedafd9a0de8d3f737ba0f48231b0f9262110?limit=1

This would return (for testnet):

{
  "pagination": {},
  "items": [
    {
      "blockhash": "00000000f959a5ed22dfa034f7957adbda91b3756700dbd29c640ca581bdba22",
      "blockheight": "1287345",
      "metadata": "444f4350524f4f465efa245c88af3bc0bf9e4392976cedafd9a0de8d3f737ba0f48231b0f9262110",
      "txid": "30e24f7132635c6b278e9d505112788ca8234dfe15ac545288d33fb675dfdf4c",
      "outputIndex": "0"
    }
  ]
}

Protocols

List all protocols

ResourceMethodRequest ObjectReturn Object
/protocolsGETProtocol Object
  • Usage:
curl http://localhost:3001/opcodes/protocols

This would return (for testnet):

{
  "items": [
    {
      "protocol": "Proof of Existence",
      "identifier": "DOCPROOF",
      "prefix": "444f4350524f4f46",
      "href": "/opcodes/metadata/444f4350524f4f46"
    },
    {
      "protocol": "Po.et",
      "identifier": "POET",
      "prefix": "504f4554",
      "href": "/opcodes/metadata/504f4554"
    },
    {
      "protocol": "Omni",
      "identifier": "Omni",
      "prefix": "6f6d6e69",
      "href": "/opcodes/metadata/6f6d6e69"
    },
    {
      "protocol": "Stampd",
      "identifier": "STAMPD##",
      "prefix": "5354414d50442323",
      "href": "/opcodes/metadata/5354414d50442323"
    },
    {
      "protocol": "Eternity Wall",
      "identifier": "EW",
      "prefix": "4557",
      "href": "/opcodes/metadata/4557"
    }
  ]
}

Identifiers

List all metadata objects that match the opcode identifier prefix

ResourceMethodRequest ObjectReturn Object
/identifiers/:identifier[?limit=1]GETMetadata Object

NOTE:

Range of limit: 1, 100, default: 10

Format of identifier: it has to be URL encoded

  • Usage:
curl http://localhost:3001/opcodes/identifiers/DOCPROOF
curl http://localhost:3001/opcodes/identifiers/DOCPROOF?limit=1

This would return (for testnet):

{
  "pagination": {},
  "items": [
    {
      "blockhash": "00000000f959a5ed22dfa034f7957adbda91b3756700dbd29c640ca581bdba22",
      "blockheight": "1287345",
      "metadata": "444f4350524f4f465efa245c88af3bc0bf9e4392976cedafd9a0de8d3f737ba0f48231b0f9262110",
      "txid": "30e24f7132635c6b278e9d505112788ca8234dfe15ac545288d33fb675dfdf4c",
      "outputIndex": "0"
    }
  ]
}