Skip to content

Base module

Ben Lu edited this page Jun 9, 2017 · 37 revisions

Base module

API endpoints

Smart Contract

  • POST smartcontract/prepare
  • POST smartcontract/send

License

  • GET license/[:color_id]
  • GET license/prepare
  • GET license/transfer/prepare
  • POST license/send

Transation

  • GET transaction/[:tx_id]
  • GET transaction/prepare
  • POST transaction/send
  • POST general-transaction/prepare

Balance

  • GET balance/[:address]

Mint

  • GET mint/prepare
  • POST mint/send

UTXO

  • GET addresses/[:address]/utxo

Smart Contract APIs

POST smartcontract/prepare

Description

Smart contract raw transaction.

Parameter

Field Type Description
address str address
oracles_multisig_address str address
code str contract binary code
contract_fee (optional) int min value 1

Sample Response

{
    "raw_tx": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff1976a9140c0a86d78bc3f71db1f969353da4769e2084bc5988acffffffff0100ca9a3b000000001976a9140c0a86d78bc3f71db1f969353da4769e2084bc5988ac010000000000000001000000"
}

POST smartcontract/send

Description

Broadcast transaction.

Parameter

raw_tx

Sample Response

{
    "tx_id": "c0daefcf66be12f4e3f426c8b08babf437d7945e70bacee492df2c4a04b801e1"
}

License APIs

GET license/[:color_id]

Description

Get license information.

Parameter

None

Sample Response

{
  "member_control": "false",
  "metadata_hash": "0000000000000000000000000000000000000000000000000000000000000123",
  "divisibility": "true",
  "name": "DiQi",
  "mint_schedule": "free",
  "description": "DiQi official",
  "metadata_link": "www.diqi.us",
  "fee_type": "fixed",
  "version": 1,
  "upper_limit": 100000000,
  "fee_collector": "1JwpnfXWxKEQHVDFDuBR3gGkNxEwFwChoP",
  "fee_rate": "0E-8",
  "issuer": "1JwpnfXWxKEQHVDFDuBR3gGkNxEwFwChoP"
}

GET license/prepare

Description

Create a new license.

Parameter

alliance_member_address, color_id, name, description, member_control, metadata_link, to_address

Sample Response

{
  "raw_tx": "01000000017e0b0880b36a7519be9ffccced0a37d100de2bbae13c41d415b683a7318cb11f00000000232103be54b29ee3ced0e6866e58469c5c0a9b7b485cadaa21cb711d5821c72185fdd0acffffffff0200e1f505000000001976a9144dbb7f813bc7899ae6a4f6b549abe7821b0e2d9088ac570400000000000000000000f76a4cf437323131303131303039373436353733373435663665363136643635313736343635373336333732363937303734363936663665356636383635366336633666356637373666373236633634303436653666366536353031303030303030303030303030303030303030303030303030303436653666366536353030303030303030303030303030303030303030303030303030306637373737373732653635373836313664373036633635326536333666366430303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030570400000000000002000000"
}

GET license/transfer/prepare

Description

Transfer control of the given license.

Parameter

from_address, to_address, color_id

POST license/send

Description

Broadcast transaction.

Parameter

raw_tx

Sample Response

{
    "tx_id": "c0daefcf66be12f4e3f426c8b08babf437d7945e70bacee492df2c4a04b801e1"
}

Transaction APIs

GET transaction/[:tx_id]

Description

Get transaction information.

Parameter

None

Sample Response

{
    "vout": [{
        "color": 0,
        "scriptPubKey":
            {
                "reqSigs": 1,
                "hex": "2102958e42b2466eebf112d33afc9231189ff5f7f0537b50bda81432c527c943da1bac",
                "addresses": ["1A7R8nWmDv4DR7x2ZFyxPt4rBCc3ZBViQF"],
                "asm": "02958e42b2466eebf112d33afc9231189ff5f7f0537b50bda81432c527c943da1b OP_CHECKSIG",
                "type": "pubkey"
            },
        "value": 0,
        "n": 0
    }],
    "blockhash": "00000cf2acf8ff6bf0c0d01cf9044161e9a320a36234a61742640fe7bd3d6679",
    "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff49483045022100f2b9b4ef2324f1d7bcfe0c5b4eea1667655fc819ec6e5f1b8c30c763c1e7876b02200b1e53ffa336fa2fa4a474f98eff62b97672efd71cd569927511a3201350ce4f01ffffffff010000000000000000232102958e42b2466eebf112d33afc9231189ff5f7f0537b50bda81432c527c943da1bac00000000d5a3465700000000",
    "vin": [{
        "coinbase": "483045022100f2b9b4ef2324f1d7bcfe0c5b4eea1667655fc819ec6e5f1b8c30c763c1e7876b02200b1e53ffa336fa2fa4a474f98eff62b97672efd71cd569927511a3201350ce4f01",
        "scriptSig":
            {
            "hex": "483045022100f2b9b4ef2324f1d7bcfe0c5b4eea1667655fc819ec6e5f1b8c30c763c1e7876b02200b1e53ffa336fa2fa4a474f98eff62b97672efd71cd569927511a3201350ce4f01",
            "asm": "3045022100f2b9b4ef2324f1d7bcfe0c5b4eea1667655fc819ec6e5f1b8c30c763c1e7876b02200b1e53ffa336fa2fa4a474f98eff62b97672efd71cd569927511a3201350ce4f01"
            },
        "sequence": 4294967295
    }],
    "txid": "c53cd739cbfd95705393602c76f954962bdf9f86686bf861c0f15aea5716bd1e",
    "blocktime": 1464247255,
    "version": 1,
    "confirmations": 4,
    "time": 1464247255,
    "locktime": 1464247253,
    "type": "NORMAL",
    "size": 176
}

GET transaction/prepare

Description

Create a simple raw transaction that sends an amount of color to another address.

Parameter

Field Type Description
from_address str address
to_address str address
color_id str color id
amount str amount
op_return_data (optional) str op return data (max 128KB)

Sample Response

{
    "raw_tx": "0100000002e3a64b94e7113edff5c9cecf5a043f3194c4bc38587600777863269823c8bcaf0100000000ffffffffe3a64b94e7113edff5c9cecf5a043f3194c4bc38587600777863269823c8bcaf0200000000ffffffff0200ca9a3b000000001976a91419349e6f4108e9a387cbd0c090e445610e1449ec88ac0200000000105e5f0000000017a91415a714cb17b9b2a9469a5b8c765df7b1b7a8a12887010000000000000000000000"
}

POST transaction/send

Description

Broadcast transaction.

Parameter

raw_tx

Sample Response

{
    "tx_id": "c0daefcf66be12f4e3f426c8b08babf437d7945e70bacee492df2c4a04b801e1"
}

POST general-transaction/prepare

Description

Create a general raw transaction that sends colors from multiple addresses to others. The first sender should pay the tx-fee. (The parameters do not include tx-fee) If you add a op_return_data to the json request, the transaction type would be automatically changed to CONTRACT.

Parameter

{
    "tx_info": 
        [
            {
                "from_address": "",
                "to_address": "",
                "color_id": "",  #str type
                "amount": ""      #str type
            },
            ......
        ],
     "op_return_data": "Hello blockchain." # (optional)
}

Sample Response

{
  "raw_tx": "01000000017e0b0880b36a7519be9ffccced0a37d100de2bbae13c41d415b683a7318cb11f00000000232103be54b29ee3ced0e6866e58469c5c0a9b7b485cadaa21cb711d5821c72185fdd0acffffffff0200e1f505000000001976a9144dbb7f813bc7899ae6a4f6b549abe7821b0e2d9088ac570400000000000000000000f76a4cf437323131303131303039373436353733373435663665363136643635313736343635373336333732363937303734363936663665356636383635366336633666356637373666373236633634303436653666366536353031303030303030303030303030303030303030303030303030303436653666366536353030303030303030303030303030303030303030303030303030306637373737373732653635373836313664373036633635326536333666366430303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030570400000000000002000000"
}

Balance APIs

GET balance/[:address]

Description

Get balance information (in BTC).

Parameter

None

Return Format

Field Type Description
color_id str amount in BTC
{
    "color_id": "<amount>"
}

Sample Response

{
    "1": "100.0000000"
}

Mint APIs

GET mint/prepare

Description

Mint raw transaction.

Parameter

Field Type Description
mint_pubkey str public key
color_id int color id
amount float amount in BTC, can less than 1

Sample Response

{
    "raw_tx": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2321033ecd74acb606a5bb7f5fdb1537b36995cc0eb1efa59ca209a974e980837a0c3aacffffffff0100e40b54020000002321033ecd74acb606a5bb7f5fdb1537b36995cc0eb1efa59ca209a974e980837a0c3aac010000000000000001000000"
}

POST mint/send

Description

Broadcast transaction.

Parameter

raw_tx

Sample Response

{
    "tx_id": "c0daefcf66be12f4e3f426c8b08babf437d7945e70bacee492df2c4a04b801e1"
}

UTXO APIs

GET addresses/[:address]/utxo

Description

Get the UTXOs of an address.

Sample Response

[
  {
    "color": 1,
    "scriptPubKey": "2102aa807427661f42517c12c230baf5af9035ece89f2312432c18063e164dab0b6cac",
    "value": "1.00000000",
    "vout": 1,
    "txid": "13fc90bf70cee8367860c615dc261e82d0666ada72c9aa6785e23dfba5b56e00"
  },
  {
    "color": 1,
    "scriptPubKey": "2102aa807427661f42517c12c230baf5af9035ece89f2312432c18063e164dab0b6cac",
    "value": "1.00000000",
    "vout": 1,
    "txid": "fcd0c7ba379b97c156a0bd78c8d3f2b9acdd42416011d0b4ccede219c2850801"
  }
]