Python JSON-RPC client for Byteball

in #utopian-io6 years ago (edited)

Repository

https://github.com/emre/byteball-rpc-client

byteball-rpc-client is a python library to interact with the headless byteball's RPC interface.

In order to access the RPC service, you need to setup a private headless wallet with RPC enabled. Once you set it up, you can use these commands:

  • getinfo (State of then DAG)
  • validateaddress (Byteball Address Validator)
  • getnewaddress (Create a new address in the headless wallet)
  • getbalance (Get the balance of the wallet or a specific address in the wallet)
  • listtransactions (Scan transactions in the wallet)
  • sendtoaddress (Withdraw funds to any other address)

bball.jpeg

Logo of Byteball

Installation

$ (sudo) pip install byteball_rpc_client

Usage

Get a Client instance first.

from byteball_rpc_client.client import Client
c = Client("your_private_rpc_server")

Commands

getinfo
c.get_info()

Output:

{
    'last_mci': 3074861,
    'last_stable_mci': 0,
    'count_unhandled': 0
}

validateaddress

c.validate_address("<any_byteball_address>")

Output will be True or False. (bool)

getnewaddress
c.get_new_address()

Output will be a string. (Ex: FRQJM2OLCY5FYPXIIHXPPZM4YYN2JYOZ)

getbalance

Get the balance of the wallet:

c.get_balance()

Output:

{
    'base': {
        'stable': 1762691,
        'pending': 0,
        'is_private': None
    }
}

Or if you want to get the balance of a single address:

c.get_balance("<address>")
listtransactions
  • Get all transactions related to a particular address
c.list_transactions(address="<address>")

Output:

[{
    'action': 'sent',
    'amount': 250000,
    'addressTo': '<address>',
    'original_address': None,
    'textAddress': '',
    'claimed': False,
    'mnemonic': None,
    'confirmations': 1,
    'unit': '<unit>',
    'fee': 541,
    'time': '<timestamp>',
    'level': None,
    'mci': <mci>,
    'isTextcoin': False
}, 
]
  • Get all transactions on the wallet after a particular MCI
c.list_transactions(since_mci="<mci>")
  • Get a specific transaction
c.list_transactions(unit="<unit_id>")

sendtoaddress

Withdraw bytes or another asset.

c.send_to_address('<receiver_address>', amount)

It has an optional asset parameter for different assets. The default is bytes.
Amount also should be in bytes.

The response will be the unit ID in a string. Ex:

wYy4kuIMJTnbnPGopBOmA1aeY16ArhfVD6UKLVZdb0g=

Notes

Current RPC server doesn't have any authentication. So, make sure you secure the access to the RPC server.

My GitHub Account

https://github.com/emre

Sort:  

Seriously mate, every post I'm awestruck....and clueless. You and Markymark need a Nobel Prize in coding.
Cobol and Basic were never like this........

Thanks for the contribution, @emrebeyler!

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Awesome project! I hope this gets some good attention great work!

RPC interface is designed for exchanges afaik. Websocket api is better for general use. (Which I will adress later on.)

Hey @emrebeyler
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

byteball:QLOPGPP4MYKOJRY5ZEDBO4TN5J5WHSJO

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.029
BTC 62907.73
ETH 2531.30
USDT 1.00
SBD 2.62