Skip to content
Steven Masley edited this page Oct 14, 2019 · 19 revisions

pegnetd Daemon RPC Documentation

This document defines the Remote Procedure Call API for pegnetd. The RPC encompasses methods to read balances, transactions, and conversions on pegnet.

The API will follow JSON-RPC 2.0 Specification.

API Version

This standard covers RPC API version v1

get-sync-status :

Return the current heights synced by pegnetd and the factomd it is communicating with.

Request:

curl -X POST --data-binary \
'{"jsonrpc": "2.0", "id": 0, "method":"get-sync-status"}' \
-H 'content-type:text/plain;' http://localhost:8070/v1

Response:

{  
   "jsonrpc":"2.0",
   "result":{  
      "syncheight":214301,
      "factomheight":214301
   },
   "id":0
}

get-transaction:

Returns if a given entry hash is a pegnet transaction, and if so returns the transaction. Because pegnet is intended to integrate with FAT, the param chainid is required, and is always cffce0f409ebba4ed236d49d89c70e4bd1f1367d86402a3363366683265a242d for all pegnet transactions and conversions.

Request:

curl -X POST --data-binary \
'{"jsonrpc": "2.0", "id": 0, "method":"get-transaction",
"params":{"chainid":"cffce0f409ebba4ed236d49d89c70e4bd1f1367d86402a3363366683265a242d","entryhash":"9254475b3a05bd275b7fdcd161dae45be4973b700a7bf0e53073a57bbcae36df"}}' \
-H 'content-type:text/plain;' http://localhost:8070/v1

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "entryhash": "9254475b3a05bd275b7fdcd161dae45be4973b700a7bf0e53073a57bbcae36df",
    "timestamp": 0,
    "data": {
      "version": 1,
      "transactions": [
        {
          "input": {
            "address": "FA2qLL7t8Te5ay5oUcjLQJhakPUnKe5rNFaCTssmaLjPz1gPwUKz",
            "amount": 361235032,
            "type": "pBRL"
          },
          "conversion": "pXBC",
          "metadata": null
        }
      ]
    }
  },
  "id": 0
}

get-pegnet-issuance :

Get the total supply for each pegnet asset.

Request:

curl -X POST --data-binary \
'{"jsonrpc": "2.0", "id": 0, "method":"get-pegnet-issuance"}' \
-H 'content-type:text/plain;' http://localhost:8070/v1

Response:

{  
   "jsonrpc":"2.0",
   "result":{  
      "syncstatus":{  
         "syncheight":214299,
         "factomheight":214299
      },
      "issuance":{  
         "PEG":5064716249706472,
         "pADA":9174741510,
         "pBNB":23964155,
         "pBRL":1915004591,
         "pCAD":505757599,
         "pCHF":2031773352,
         "pCNY":2716169709,
         "pDASH":5317841,
         "pDCR":21694146,
         "pETH":1838430641,
         "pEUR":427187617,
         "pFCT":3846027468077,
         "pGBP":308496745,
         "pHKD":2980001159,
         "pINR":26981732013,
         "pJPY":40694137315,
         "pKRW":454720374337,
         "pLTC":6640888,
         "pMXN":7428080364,
         "pPHP":19717349003,
         "pRVN":14391145402388,
         "pSGD":524774284,
         "pUSD":368327645950,
         "pXAG":10029803207,
         "pXAU":144804349,
         "pXBC":1623103,
         "pXBT":42136027,
         "pXLM":6158039443,
         "pXMR":6690407,
         "pZEC":10101202
      }
   },
   "id":0
}

get-pegnet-balances :

Get the pegnet asset balances for a given address. All balances are in their fixed point values, meaning a balance of 1e8 == 1 pAsset. In this example response, the address has 9401 PEG.

Request:

curl -X POST --data-binary \
'{"jsonrpc": "2.0", "id": 0, "method":"get-pegnet-balances",
"params":{"address":"FA28MV2VvvsdjjgXoHwsadtMWqM5mt7bZU3hMjLuDLLN1DBhK48g"}}' \
-H 'content-type:text/plain;' http://localhost:8070/v1

Response:

{
   "jsonrpc":"2.0",
   "result":{
      "PEG":940100000000,
      "pADA":0,
      "pBNB":0,
      "pBRL":0,
      "pCAD":0,
      "pCHF":0,
      "pCNY":0,
      "pDASH":0,
      "pDCR":0,
      "pETH":0,
      "pEUR":0,
      "pFCT":0,
      "pGBP":0,
      "pHKD":0,
      "pINR":0,
      "pJPY":0,
      "pKRW":0,
      "pLTC":0,
      "pMXN":0,
      "pPHP":0,
      "pRVN":0,
      "pSGD":0,
      "pUSD":0,
      "pXAG":0,
      "pXAU":0,
      "pXBC":0,
      "pXBT":0,
      "pXLM":0,
      "pXMR":0,
      "pZEC":0
   },
   "id":0
}

get-pegnet-rates:

Returns the pegnet conversion rates for a given block height.

Request:

curl -X POST --data-binary \
'{"jsonrpc": "2.0", "id": 0, "method":"get-pegnet-rates",
"params":{"height":213000}}' \
-H 'content-type:text/plain;' http://localhost:8070/v1

Response:

{
  "jsonrpc": "2.0",
  "result": {
    "PEG": 0,
    "pADA": 3974089,
    "pBNB": 1567649568,
    "pBRL": 24646300,
    "pCAD": 75119063,
    "pCHF": 100467172,
    "pCNY": 13989136,
    "pDASH": 6946832822,
    "pDCR": 1668878643,
    "pETH": 17633014348,
    "pEUR": 109799615,
    "pFCT": 362154294,
    "pGBP": 123334369,
    "pHKD": 12755583,
    "pINR": 1411920,
    "pJPY": 935059,
    "pKRW": 83871,
    "pLTC": 5736385888,
    "pMXN": 5124197,
    "pPHP": 1935040,
    "pRVN": 3086664,
    "pSGD": 72519997,
    "pUSD": 100000000,
    "pXAG": 1753985933,
    "pXAU": 150375939849,
    "pXBC": 22310754166,
    "pXBT": 812762606639,
    "pXLM": 5913512,
    "pXMR": 5669451886,
    "pZEC": 3700509005
  },
  "id": 0
}