Python SDK for interacting with QLC node
Project description
qlc-python-SDK
Examples
Create 3 random accounts
from pyqlc.client import Client
def example():
qlc = Client("http://127.0.0.1:9735")
accounts = qlc.Account.newAccounts(3)
for idx, addr in enumerate(accounts):
print(f"{idx} ==> {addr}")
example()
"""
Output:
0 ==> {
'address': 'qlc_1i5emtz19w75cnzpcm3gn96smp4se8s5cn8potw7si456tapz3npemjwwami',
'privKey': b'cc8f2fb68202526ebab7a968fa81883c29785dc4599e46126f422b11f4402f3f406c9ebe03f0a3553f654c2ea1c999d85961b23550d6aeb85cc04326916f8696',
'pubKey': b'406c9ebe03f0a3553f654c2ea1c999d85961b23550d6aeb85cc04326916f8696',
'seed': '7e6cbeb02e3247ae82fd0f0eb5030ed857c516f5fa4bba513ede65dffa863d31'
}
1 ==> {
'address': 'qlc_3duidxc7cuizuoj8gx7crpykbibweqe9kpc9fsgohz6arfzowoki5ip7ddcw',
'privKey': b'ba9f8339fc6b0950d5b3afa3aaaad1518d32d098aa3f2715e1247acf45a72569af705f54556e1fdd626774aac5bd24c13c65d87959476e5d57fc88c37f5e5650',
'pubKey': b'af705f54556e1fdd626774aac5bd24c13c65d87959476e5d57fc88c37f5e5650',
'seed': '256d61e9a26f1209e62daff747e2caa959211324c1ffee04df3bbdeaa5c197d4'
}
2 ==> {
'address': 'qlc_3pe9cd67cbhtjgh67g79qdi9o8poto9jnyznsk5ofb6u8xaf1urnytsno345',
'privKey': b'5e8d3b00cef26f73660144287dbe0c705825ba780fcba1828d41dd423cd5dc7ad98752c85525fa8b9e42b8a7bae07a9ad5d54f1a7bf4cc8756a49b3750d06f14',
'pubKey': b'd98752c85525fa8b9e42b8a7bae07a9ad5d54f1a7bf4cc8756a49b3750d06f14',
'seed': 'd20d72e3fb07b4936d8eee49cb23cf4e796fca566af07eaaf6c8578ab257103b'
}
"""
Sending transaction
from pyqlc.client import Client
import json
def main():
qlc = Client("https://rpc.qlcchain.online/")
Alice = {
"address" : "qlc_3xc5fbrqck6mrxrrx7hjnqf6jgyqsnkeg39k5mjw44m8aj3f1zdfh7cw8kzz",
"private_key" : "8e6bc788bbeae46f26315dd91bbbc6891278bf3bfb228aa901b39f3f1c169efbf5436a71754893c7718e95f1a5da48bbd7cd24c704f21ce3c10a664332d07d6d"
}
seed = qlc.Account.newSeed(local= True)
new_account = qlc.Account.create(seed= seed, index= 0, local= True)
Bob = {
"address" : new_account["address"]
}
send_block = qlc.Ledger.generateSendBlock(From= Alice["address"], to= Bob["address"], tokenName= "QGAS", amount=1, privKey= Alice["private_key"])
print(f"block = {json.dumps(send_block, indent= 4)}")
_hash = qlc.Ledger.process(**send_block)
print(f"hash = {_hash}")
main()
"""
Output:
block = {
"type": "Send",
"token": "ea842234e4dc5b17c33b35f99b5b86111a3af0bd8e4a8822602b866711de6d81",
"address": "qlc_3xc5fbrqck6mrxrrx7hjnqf6jgyqsnkeg39k5mjw44m8aj3f1zdfh7cw8kfz",
"balance": "346854",
"vote": "0",
"network": "0",
"storage": "0",
"oracle": "0",
"previous": "738642163581ddab31e171813abd1301bb7d14c7f470ca91f65717710c45a464",
"link": "42d2f239db3798b1f60b182e72790e71fe805e0eb62eef7a2e06646d71cfc695",
"message": "0000000000000000000000000000000000000000000000000000000000000000",
"povHeight": 514397,
"timestamp": 1613280327,
"extra": "0000000000000000000000000000000000000000000000000000000000000000",
"representative": "qlc_1111111111111111111111111111111111111111111111111111hifc8npp",
"work": "0000000000a70611",
"signature": "f01b8100ab050bd8efed9585f88ae4777c86fd050053b43a3bca2ec5e04c5cefdc12b108eaec792bb70ebe546a7dbdf6f63ca34a4eb6cf95b93259cae6cc970b"
}
hash = 6014521eb956b589013540174951ba690cde4f2d98b0fbc291f0f94ac1bbbb87
"""
Requirements
$ pip3 install -r requirements.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyqlc-0.0.3.tar.gz
(36.8 kB
view details)
Built Distribution
File details
Details for the file pyqlc-0.0.3.tar.gz
.
File metadata
- Download URL: pyqlc-0.0.3.tar.gz
- Upload date:
- Size: 36.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47af4a1a072de3a94db83b9e0a22103193dc742cb254587669781f9432b97e8b |
|
MD5 | e3bf883b4794b37c06914c446afa943e |
|
BLAKE2b-256 | fb11b0e2f0e80a067f5665dc478bdae9666837583bce32bbdc44e2e2d6d5fda7 |
File details
Details for the file pyqlc-0.0.3-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pyqlc-0.0.3-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 85.5 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.24.0 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9883d9c7d5de4697967fc5c3da8ba7acdd5ad2147269ee6ac43d3921fd42c8d9 |
|
MD5 | 8bbc3baac19463f41d05f901ee7b8bdb |
|
BLAKE2b-256 | de04f31ff3c2ffbd710d899e8a6912894700ebd5391e204f02eefabce9c0b8a2 |