create account

Python JSON-RPC client for Byteball by emrebeyler

View this thread on: hive.blogpeakd.comecency.com
· @emrebeyler · (edited)
$115.39
Python JSON-RPC client for Byteball
#### Repository
https://github.com/emre/byteball-rpc-client

byteball-rpc-client is a python library to interact with the [headless byteball](https://github.com/byteball/headless-byteball)'s RPC interface. 

In order to access the RPC service, you need to [setup a private headless wallet with RPC enabled](https://github.com/byteball/headless-byteball/wiki/Running-RPC-service). 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](https://ipfs.busy.org/ipfs/QmSipbrs6EzPS2RqMV31XKDmCLKac5X6edhG9rp471XEPd)
<center><sup>Logo of Byteball</sup></center>

#### Installation

```
$ (sudo) pip install byteball_rpc_client
```

#### Usage

Get a ```Client``` instance first.

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

#### Commands
##### getinfo 

```python
c.get_info()
```

Output:

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

#### validateaddress 

```python
c.validate_address("<any_byteball_address>")
```

Output will be True or False. (bool)

##### getnewaddress

```python
c.get_new_address()
```

Output will be a string. (Ex: ```FRQJM2OLCY5FYPXIIHXPPZM4YYN2JYOZ```)

##### getbalance

Get the balance of the wallet:

```python
c.get_balance()
```

Output:

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

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

```python
c.get_balance("<address>")
```

##### listtransactions

- Get all transactions related to a particular address

```python
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

```python
c.list_transactions(since_mci="<mci>")
```

- Get a specific transaction

```python
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
πŸ‘  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 180 others
properties (23)
authoremrebeyler
permlinkpython-json-rpc-client-for-byteball
categoryutopian-io
json_metadata{"community":"busy","app":"busy/2.5.3","format":"markdown","tags":["utopian-io","development","byteball","busy","sndbox"],"users":[],"links":["https://github.com/emre/byteball-rpc-client","https://github.com/byteball/headless-byteball","https://github.com/byteball/headless-byteball/wiki/Running-RPC-service","https://github.com/emre"],"image":["https://ipfs.busy.org/ipfs/QmSipbrs6EzPS2RqMV31XKDmCLKac5X6edhG9rp471XEPd"]}
created2018-07-18 15:20:03
last_update2018-07-18 15:51:12
depth0
children6
last_payout2018-07-25 15:20:03
cashout_time1969-12-31 23:59:59
total_payout_value89.886 HBD
curator_payout_value25.506 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,001
author_reputation448,528,959,341,273
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,129,421
net_rshares54,759,437,664,195
author_curate_reward""
vote details (244)
@amosbastian ·
$0.07
Thanks for the contribution, @emrebeyler!

Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/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](https://review.utopian.io/result/3/2231122).

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
πŸ‘  , , ,
properties (23)
authoramosbastian
permlinkre-emrebeyler-python-json-rpc-client-for-byteball-20180718t220058760z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["emrebeyler"],"links":["https://join.utopian.io/guidelines","https://review.utopian.io/result/3/2231122","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-07-18 22:00:57
last_update2018-07-18 22:00:57
depth1
children0
last_payout2018-07-25 22:00:57
cashout_time1969-12-31 23:59:59
total_payout_value0.052 HBD
curator_payout_value0.015 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length532
author_reputation174,473,586,900,705
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,166,350
net_rshares32,947,866,639
author_curate_reward""
vote details (4)
@ceruleanblue ·
Awesome project! I hope this gets some good attention great work!
properties (22)
authorceruleanblue
permlinkre-emrebeyler-python-json-rpc-client-for-byteball-20180718t155100867z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-07-18 15:51:03
last_update2018-07-18 15:51:03
depth1
children1
last_payout2018-07-25 15:51:03
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length65
author_reputation3,400,370,914,590
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd0
post_id65,132,857
net_rshares0
@emrebeyler ·
RPC interface is designed for exchanges afaik. Websocket api is better for general use. (Which I will adress later on.)
properties (22)
authoremrebeyler
permlinkre-ceruleanblue-re-emrebeyler-python-json-rpc-client-for-byteball-20180718t160911912z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-07-18 16:09:12
last_update2018-07-18 16:09:12
depth2
children0
last_payout2018-07-25 16:09:12
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length119
author_reputation448,528,959,341,273
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,134,819
net_rshares0
@darksideofmoon ·
byteball:QLOPGPP4MYKOJRY5ZEDBO4TN5J5WHSJO
πŸ‘Ž  
properties (23)
authordarksideofmoon
permlinkre-emrebeyler-python-json-rpc-client-for-byteball-20180718t155118730z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-07-18 15:51:21
last_update2018-07-18 15:51:21
depth1
children0
last_payout2018-07-25 15:51:21
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length41
author_reputation-409,989,617,720
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,132,894
net_rshares-61,674,782,808
author_curate_reward""
vote details (1)
@nathen007 ·
$0.15
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........
πŸ‘  
properties (23)
authornathen007
permlinkre-emrebeyler-python-json-rpc-client-for-byteball-20180718t163823014z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-07-18 16:38:21
last_update2018-07-18 16:38:21
depth1
children0
last_payout2018-07-25 16:38:21
cashout_time1969-12-31 23:59:59
total_payout_value0.133 HBD
curator_payout_value0.015 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length150
author_reputation258,444,909,480,655
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,137,973
net_rshares71,091,801,918
author_curate_reward""
vote details (1)
@utopian-io ·
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.**

<a href='https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1'>Vote for Utopian Witness!</a>
properties (22)
authorutopian-io
permlinkre-python-json-rpc-client-for-byteball-20180721t212009z
categoryutopian-io
json_metadata"{"app": "beem/0.19.42"}"
created2018-07-21 21:20:09
last_update2018-07-21 21:20:09
depth1
children0
last_payout2018-07-28 21:20:09
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length302
author_reputation152,955,367,999,756
root_title"Python JSON-RPC client for Byteball"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id65,517,179
net_rshares0