Server API

The daemon implements JSON RPC, so you can use any RPC client to communicate with it or write your own. A basic request over HTTP would look like this (using testnet4 endpoint)

POST http://127.0.0.1:7225

{
    "jsonrpc": "2.0", 
    "method": "<methodname>", 
    "params": [ .. ],
    "id": 1
}

Get Server Info

getserverinfo retrieve the current state of the spaces daemon

Params None

space-cli getserverinfo

Example Response

{
  "chain": "mainnet",
  "tip": {
    "hash": "0000000000000000000210254eedf4507d3df7bf258ed4bcedfcbb8d02df58c6",
    "height": 883338
  }
}

Get Space

getspace retrieve information about a space:

Params

Name
Type
Description

space

string

Canonical space name e.g. @bitcoin

space-cli getspace @bitcoin

Example Response


{
  "txid": "83e11748b0eb15b4ee26f35d3bffe13d35d66d055de4a42a41a06d646879f994",
  "n": 1,
  "name": "@btc",
  "covenant": {
    "type": "bid",
    "burn_increment": 1000,
    "signature": "........",
    "total_burned": 1000,
    "claim_height": null
  },
  "value": 662,
  "script_pubkey": "........"
}

Get Space Owner

getspaceowner retrieves the outpoint of a space:

Params

Name
Type
Description

space

string

Canonical space name e.g. @bitcoin

only available via JSON-RPC

Example Response Responds with an outpoint with txid:vout format.

"3ac9772d3451bd0b2a7cfa09c3eecebdbfb54bbdf90f322e7e7fa6dee3bc0def:1"

Get Spaceout

getspaceout retrieves a spaceout which are any UTXOs tracked by the spaces protocol not necessarily ones with a space.

Params

Name
Type
Description

outpoint

string

An Outpoint which is a specific output within a transaction using txid:vout format e.g.

3ac9772d3451bd0b2a7cfa09c3eecebdbfb54bbdf90f322e7e7fa6dee3bc0def:1
space-cli getspaceout "3ac9772d3451bd0b2a7cfa09c3eecebdbfb54bbdf90f322e7e7fa6dee3bc0def:1"

Example Response

{
  "n": 1,
  "name": "@bitcoin",
  "covenant": {
    "type": "transfer",
    "expire_height": 925977,
    "data": null
  },
  "value": 666,
  "script_pubkey": "........"
}

Estimate bid

estimatebid estimates the required bid to make it into the auctions phase for the given interval (in 144 block increments)::

Params

Name
Type
Description

target

number

The target interval e.g. specify 0 for the coming rollout, 1 for the day after and so on.

space-cli estimatebid 0

Example Response Responds with an amount in Satoshis

2000

Get Rollout

getrollout get spaces rolling out into auctions for the given interval (in 144 block increments):

Params

Name
Type
Description

target

number

The target interval e.g. specify 0 for the coming rollout, 1 for the day after and so on.

space-cli getrollout 0

Example Response An array of spaces expected to be in auctions within the given target

[
  [
    "@bitcoin",
    1000
  ],
  [
    "@mytestspace",
    1000
  ],

Get Block Meta

getblockmeta Retrieves all transactions relevant to spaces for the given block (requires block indexing to be enabled)

Params

Name
Type
Description

block_hash

string

The block hash as hex string

only available via JSON-RPC

Example Response

{
  "height": 55879,
  "tx_meta": [
    {
      "txid": "394ebef5203c4306c3f7a6d1a5c2058bac130deb24c1d7725094b31d1ff54ea4",
      "spends": [
        {
          "n": 0
        }
      ],
      "creates": [
        {
          "n": 0,
          "value": 662,
          "script_pubkey": "........"
        }
      ],
      "updates": []
    },
    {
      "txid": "f811529d79c9fc808c240a1b5087ba19610c4177a01ffa8047c3cc143cf3eb1a",
      "spends": [
        {
          "n": 0
        },
        {
          "n": 1
        },
        {
          "n": 2
        },
        {
          "n": 3
        }
      ],
      "creates": [
        {
          "n": 1,
          "name": "@bitcoin",
          "covenant": {
            "type": "transfer",
            "expire_height": 108439,
            "data": "68656c6c6f20776f726c64"
          },
          "value": 666,
          "script_pubkey": "........"
        }
      ],
      "updates": []
    }
  ]
}

Get Transaction Meta

gettxmeta Retrieves all transactions relevant to spaces for the given block (requires -txindex to be enabled)

Params

Name
Type
Description

txid

string

The transaction id as a hex string

only available via JSON-RPC

Example Response

{
  "txid": "394ebef5203c4306c3f7a6d1a5c2058bac130deb24c1d7725094b31d1ff54ea4",
  "spends": [
    {
      "n": 0
    }
  ],
  "creates": [
    {
      "n": 0,
      "value": 662,
      "script_pubkey": "........"
    }
  ],
  "updates": []
}

Check package

checkpackage Simulates the transactions being applied to the current blockchain state

Params

Name
Type
Description

txs

array of strings

The transactions as hex strings

only available via JSON-RPC

Example Response

[
  {
    "txid": "e318d853699b3f6c734d19ccb8a04b0428252fd8ef0e650c23fd07edc9a1e438",
    "spends": [
      {
        "n": 1
      }
    ],
    "creates": [
      {
        "n": 0,
        "value": 2,
        "script_pubkey": "........"
      },
      {
        "n": 1,
        "value": 1662,
        "script_pubkey": "........"
      }
    ],
    "updates": [
      {
        "type": "revoke",
        "reason": "bid_psbt_output_spent",
        "output": {
          "txid": "2a6fb4db5cd40ddccb4d49ada1caa78ea313ae6bae8b47ca12fd6f45a589ba75",
          "n": 1,
          "name": "@space",
          "covenant": {
            "type": "bid",
            "burn_increment": 1000,
            "signature": "........",
            "total_burned": 1000,
            "claim_height": null
          },
          "value": 662,
          "script_pubkey": "........"
        }
      }
    ]
  }
]

Last updated

Was this helpful?