DogeChain is an Ethereum Virtual Machine (EVM) compatible network that has a JSON RPC API you can use to retrieve transaction data, blocks, and much more from its blockchain. If you are an Ethereum developer, these commands will look familiar. If not, have no fear. This article has you covered!

How does the DogeChain JSON RPC API work? A DogeChain node stores a copy of the blockchain and provides methods you can use to retrieve the data using standard HTTP POST requests that you would send to the RPC API. POST requests are used for this instead of GET requests because they are more secure.

The flow of data looks like this: DogeChain Node’s Copy Of The Blockchain >> JSON RPC API >> Your App.

In this article, i’ll show you how to send requests like those mentioned above using Node.js. Afterwards, you can make your Node.js app provide the data to a mobile app or website if you wish.


Install Node.js on Ubuntu or Debian (the example code herein was tested with Node.js version 10.19.0, although it will work with many other versions):

sudo apt install nodejs

If you use freeBSD:

pkg install node

Instructions for RedHat

Install npm:

sudo apt install npm

Create a directory called dogerpc and enter it, then install the required dependency called ‘request-promise’ which we will use to build our HTTP requests and send them off to the DogeChain RPC API:

npm install request-promise

Retrieve The Details Of A DogeChain Transaction

Create a file in the same dogerpc directory called mydogeapp.js, and start it off with the following sample code:

const rp = require('request-promise');

const rpcuri = ""; //This is the node we're sending the HTTP request to

function getTransactionByHash(hash) {
    const requestOptions = {
        method: 'POST',
        uri: rpcuri,
        body: {
        json: true,
        gzip: true
    rp(requestOptions).then(response => {
        console.log(response); //Response contains the blockchain data you requested, if it exists.
    }).catch((err) => {
        console.log('API call error:', err.message);

getTransactionByHash('0x5de411b96b3e264227d690d9af7e98e2738cff50c879b77793028e614b8b948e'); //A real transaction hash on the testnet, so you won't have to find one.

The ‘rpcuri’ variable contains whichever node you’ve chosen to use. You can change it to whichever node you like, including your own.

Note the method used, which is ‘eth_getTransactionByHash’. The method field tells the RPC server what type of data you are requesting. In this case, you are requesting the details of a transaction, and ‘by hash’ means that you’re stating your intent to search for the transaction using its hash. The server will send you details about the quantity sent in that transaction (the ‘value’ field), the gas fee paid, and much more.

The ‘params’ field tells the server exactly which data you are searching for, and in this case it must be a transaction hash — as stated by the ‘method’ field.

Learn how functions work

The server should respond with the following data:

{ jsonrpc: '2.0',
  id: 1,
   { nonce: '0xe4f',
     gasPrice: '0x174876e800',
     gas: '0x1c9c380',
     to: '0xE7FfFd87c82a84167DbEa69915a5A7e6B772e3E4',
     value: '0x8ac7230489e80000',
     input: '0x',
     v: '0x493',
     from: '0x4F87e677D1244Fc776E62289e8E4d44Ff51b969f',
     blockNumber: '0x16f158',
     transactionIndex: '0x0' } }

Parsing: If, for example you just wanted to find the amount sent in the transaction, you could change the ‘console.log(response);‘ line to: ‘console.log(response.result.value);‘.

How To Retrieve A DogeChain Block

You can retrieve the data contained in a DogeChain block (eg. transactions, miner details, size, difficulty, and much more) using the ‘eth_getBlockByHash’ method, as shown below:

const rp = require('request-promise');

const rpcuri = ""; //This is the node we're sending the HTTP request to

function getBlockByHash(hash) {
    const requestOptions = {
        method: 'POST',
        uri: rpcuri,
        body: {
            "jsonrpc":"2.0","method":"eth_getBlockByHash","params":[hash, false],"id":67
        json: true,
        gzip: true
    rp(requestOptions).then(response => {
    }).catch((err) => {
        console.log('API call error:', err.message);


The code samples above are very similar because they are simply sending your desired methods and parameters to the JSON RPC server. There are other methods you can use to retrieve other kinds of blockchain data using the code samples above as a template, including but not limited to:

  • eth_getBlockByNumber
  • eth_gasPrice
  • eth_getBalance
  • eth_sendTransaction

The server’s response should look like this:

{ jsonrpc: '2.0',
  id: 67,
   { parentHash:
     miner: '0x7945EB690589dCfd424457E030234AD8f7204FC4',
     difficulty: '0x16f158',
     totalDifficulty: '0x16f158',
     size: '0x403',
     number: '0x16f158',
     gasLimit: '0x1c9c380',
     gasUsed: '0x5208',
     timestamp: '0x62994f43',
     nonce: '0x0000000000000000',
      [ '0x5de411b96b3e264227d690d9af7e98e2738cff50c879b77793028e614b8b948e' ],
     uncles: [] } }

The code examples above can be easily implemented in the form of a module to use in your apps or bots.

Node.js Code Examples Tested with:

  • Node.js version 10.19.0.
  • request-promise version 4.2.5.

Python Code Sample: Get The Contents Of A DogeChain Block

Create a file named, paste the following into it and run it with Python 3. The ‘method’ and ‘params’ fields work the same as they do in the examples above. Feel free to change them to use whichever other method you’d like to use from the DogeChain JSON RPC API.

import requests

nodeurl = '' #Address/url of the node
requestbody = {"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0x922e80cf4f376abfbe4d62d08681c70970aa6d347cf8ad2908045093bd0a670a"],"id":67}
#Replace the '0x' string highlighted in blue above with the hash of the block that you're seeking.
response =, json = requestbody) #Sends off the request to the node and saves the response in 'response'

print(response.text) #Prints the response sent by the DogeChain node to the command line

Python Code Example Tested With:

  • Python version 3.10.4.
  • Requests version 2.25.1.