Developer API

Xoken Nexa - Developer API
The API request & response messages are encoded using CBOR, which is an efficient binary encoding format.

Get Block by block height


Inputs: 
- Block height : Integer
Output:
- Block : BlockRecord
Method: 'HEIGHT->BLOCK'

Get Blocks by block heights


Inputs: 
- Block heights : Integer array
Output:
- Blocks : BlockRecord array
Method: '[HEIGHT]->[BLOCK]'

Get Block by block hash


Inputs: 
- Block hash : String
Output:
- Block : BlockRecord
Method: 'HASH->BLOCK'

Get Blocks by block hashes


Inputs: 
- Block hashes : String array
Output:
- Blocks : BlockRecord array
Method: '[HASH]->[BLOCK]'

Get Transaction by TxID


Inputs: 
- TxID : String
  Output:
- Transaction : TxRecord
Method: 'TXID->TX'

Get Transactions by TxIDs


Inputs: 
- TxIDs : String array
Output:
- Transactions : TxRecord array
Method: '[TXID]->[TX]'

Get Outputs by Address


Inputs: 
- Address : String
  Output:
- Outputs : AddressOutputs array
Method: 'ADDR->[OUTPUT]'

Get Outputs by Addresses


Inputs: 
- Address : String array
Output:
- Outputs : AddressOutputs array
Method: '[ADDR]->[OUTPUT]'

Get MerkleProof by TxID


Inputs: 
- TxID : String
  Output:
- MekleProof : MerkleBranchNode array
Method: 'TXID->[MNODE]'

RPCMessage

data RPCMessage
    = RPCRequest
          { rqMethod :: String
          , rqParams :: Maybe RPCReqParams
          }
    | RPCResponse
          { rsStatusCode :: Int16
          , rsStatusMessage :: Maybe String
          , rsBody :: Maybe RPCResponseBody
          }
    deriving (Show, Generic, Hashable, Eq, Serialise)
		

RPCReqParams

data RPCReqParams
    = GetBlockByHeight
          { gbHeight :: Int
          }
    | GetBlocksByHeight
          { gbHeights :: [Int]
          }
    | GetBlockByHash
          { gbBlockHash :: String
          }
    | GetBlocksByHashes
          { gbBlockHashes :: [String]
          }
    | GetTransactionByTxID
          { gtTxHash :: String
          }
    | GetTransactionsByTxIDs
          { gtTxHashes :: [String]
          }
    | GetOutputsByAddress
          { gaAddrOutputs :: String
          }
    | GetOutputsByAddresses
          { gasAddrOutputs :: [String]
          }
    | GetMerkleBranchByTxID
          { gmbMerkleBranch :: String
          }
    deriving (Generic, Show, Hashable, Eq, Serialise)

RPCResponseBody

data RPCResponseBody
    = RespBlockByHeight
          { block :: BlockRecord
          }
    | RespBlocksByHeight
          { blocks :: [BlockRecord]
          }
    | RespBlockByHash
          { block :: BlockRecord
          }
    | RespBlocksByHashes
          { blocks :: [BlockRecord]
          }
    | RespTransactionByTxID
          { tx :: TxRecord
          }
    | RespTransactionsByTxIDs
          { txs :: [TxRecord]
          }
    | RespOutputsByAddress
          { saddressOutputs :: [AddressOutputs]
          }
    | RespOutputsByAddresses
          { maddressOutputs :: [AddressOutputs]
          }
    | RespMerkleBranchByTxID
          { merkleBranch :: [MerkleBranchNode']
          }
    deriving (Generic, Show, Hashable, Eq, Serialise)

BlockRecord

data BlockRecord =
    BlockRecord
        { rbHeight :: Int
        , rbHash :: String
        , rbHeader :: String
        }
    deriving (Generic, Show, Hashable, Eq, Serialise)

TxRecord

data TxRecord =
    TxRecord
        { txId :: String
        , txBlockInfo :: BlockInfo'
        , txSerialized :: C.ByteString
        }
    deriving (Show, Generic, Hashable, Eq, Serialise)

AddressOutputs

data AddressOutputs =
    AddressOutputs
        { aoAddress :: String
        , aoOutput :: OutPoint'
        , aoBlockInfo :: BlockInfo'
        , aoIsBlockConfirmed :: Bool
        , aoIsOutputSpent :: Bool
        , aoIsTypeReceive :: Bool
        , aoOtherAddress :: String
        , aoPrevOutpoint :: OutPoint'
        , aoValue :: Int64
        }
    deriving (Show, Generic, Hashable, Eq, Serialise)

OutPoint

data OutPoint' =
    OutPoint'
        { opTxHash :: String
        , opIndex :: Int
        }
    deriving (Show, Generic, Hashable, Eq, Serialise)

BlockInfo

data BlockInfo' =
    BlockInfo'
        { binfBlockHash :: String
        , binfTxIndex :: Int
        , binfBlockHeight :: Int
        }
    deriving (Show, Generic, Hashable, Eq, Serialise)

MerkleBranchNode

data MerkleBranchNode' =
    MerkleBranchNode'
        { nodeValue :: String
        , isLeftNode :: Bool
        }
    deriving (Show, Generic, Hashable, Eq, Serialise)