Ravencoin Core JSON RPC and Python Requests

Taking a look at Ravencoin Core Wallet’s JSON RPC capabilities, and dragging you along 🙂

Before I begin let me state I’m still very new to Ravecoin, and even more so with the JSON RPC capabilities. What I do know is Ravencoin is a code fork of Bitcoin, so I’m sure some of the documentation will overlap.

This article helped me get up and running, thanks cryptobullsh!

Another source that has helped: https://rdrr.io/rforge/rbtc/man/getrawtransaction.html

Exploration

I decided I did not want to download the ~40GB of blockchain for my initial exploration, so my raven.conf looks as follows:

#Accept cli/json RPC
server=1

#Username and password - You can make this whatever you want.
rpcuser=ravenUser
rpcpassword=ravenPassword

#What IP address is allowed to make calls to the RPC server.
rpcallowip=127.0.0.1

After making this config change I restarted Raven Core and looked up a recent Asset creation:
(transaction ID: af73af5e9c1cb6abbf1085e2220be742e707902a40781245eb5ceebf2b59cc72)

Next up I’m jumping into a IPython shell, importing the Requests library, setting my local RPC url (with username/password), and the transaction ID I saw in the GUI:

In [1]: import requests

In [2]: import json

In [3]: url = 'http://ravenUser:ravenPassword@127.0.0.1:8766'

In [4]: tx = 'af73af5e9c1cb6abbf1085e2220be742e707902a40781245eb5ceebf2b59cc72'

In [5]: msg = {"id": 0, "method": "getrawtransaction", "params": {'txid': tx, 'verbose': True}, "jsonrpc": "2.0"}

With that crafted, lets make the HTTP POST request and check the response:

In [6]: res = requests.post(url, data=json.dumps(msg))

In [7]: res
Out[7]: <Response [200]>

Since our response returned a 200 OK lets check our JSON response data:

In [9]: res.json().keys()
Out[9]: dict_keys(['result', 'error', 'id'])

In [10]: res.json()['result'].keys()
Out[10]: dict_keys(['txid', 'hash', 'version', 'size', 'vsize', 'locktime', 'vin', 'vout', 'hex', 'blockhash', 'height', 'confirmations', 'time', 'blocktime'])

Lets see if I can find those asset details:

In [20]: res.json()['result']['vout'][3]['scriptPubKey']['asset']
Out[20]:
{'name': 'NESSY#Erik_Wolfeye',
 'amount': 1.0,
 'expire_time': 123145318492160,
 'units': 0,
 'reissuable': 0,
 'ipfs_hash': 'Qmc2wkKd3TieWMENaBtPhADxvr42t8pMia1Kx461LS74Vr'}

And finally lets plug that ipfs_hash into our browser: https://cloudflare-ipfs.com/ipfs/Qmc2wkKd3TieWMENaBtPhADxvr42t8pMia1Kx461LS74Vr

I ended up putting a lot of this into a simple Python module on Github, enjoy! https://github.com/jness/raventool

Minted my first Unique Ravencoin Art Asset

Using my newly created main asset I minted my first Ravencoin art asset, one of my hand painted Warhammer miniatures Erik Wolfeye!

To keep things exciting going to do a peer to peer trade on Twitter!

NESSY Assets / Tokens on Ravecoin Network

Well its official, I’ve spent 500 Ravencoin to secure the unique asset name NESSY!