UUOS API
uuos api overview
Import uuosapi
from uuoskit import uuosapi
create_key
Create a new password
uuosapi.create_key()
Return value
{
'public':'EOS8Gbv4v7oLnWC3pQwg4tJHbv7cQFuxuDnHAFKrbiVtmKx6VHBwK',
'private':'5J6NzFGPDJDFzaiRzezeJwvNHomY91oaDYnQT8kraKUPm6y1bZ5'
}
create_account
Create a new account. Before creating new account, determine that owner key’s and active key’s private keys have been imported into the wallet, and then create an account with the corresponding public key.
#Import wallet first
#Execute the command first: wallet.import_key(wallet_name,private_key)
uuosapi.create_account('eosio',account_name,owner_public_key,active_public_key)
For more wallet api, please visit walletapi.html
get_info
Returns an object containing various details about the blockchain.
uuosapi.get_info()
get_block
Returns an object containing various details about a specific block on the blockchain.
uuosapi.get_block(block_num_or_id)
get_block_header_state
Returns producer’s information
uuosapi.get_block_header_state(block_num_or_id)
get_account
Returns account’s information
uuosapi.get_account('eosio')
get_abi
Returns contract’s information
uuosapi.get_abi('eosio.token')
get_code
Returns smart contract’s code
uuosapi.get_code('eosio.token')
get_raw_code_and_abi
Returns smart contract’s binary code and abi
uuosapi.get_raw_code_and_abi('eosio.token')
get_table_rows
uuosapi.get_table_rows(True, 'uuos.token', 'UUOS', 'stat', 'UUOS', '', '', 1)
{
"rows": [
{
"supply": "1000000000.0000 UUOS",
"max_supply": "11000000000.0000 UUOS",
"issuer": "uuos"
}
],
"more": false,
"next_key": ""
}
uuosapi.get_table_rows(True, 'uuos.token', 'uuos', 'accounts', 'uuos', '', '', 1)
{
"rows": [
{
"balance": "589984541.9856 UUOS"
}
],
"more": false,
"next_key": ""
}
abi_json_to_bin
Serialize json to hexadecimal codes
args = {'from':'inita', 'to':'initb', 'quantity':'1.0000 EOS', 'memo':'hello,world'}
uuosapi.abi_json_to_bin('eosio.token', 'transfer', args)
Returns
{
"binargs": "000000000093dd74000000008093dd74102700000000000004454f53000000000b68656c6c6f2c776f726c64"
}
abi_bin_to_json
Serialize hexadecimal codes to json
binargs = "000000000093dd74000000008093dd74102700000000000004454f53000000000b68656c6c6f2c776f726c64"
uuosapi.abi_bin_to_json('eosio.token', 'transfer', binargs)
{
"args": {
"from": "inita",
"to": "initb",
"quantity": "1.0000 EOS",
"memo": "hello,world"
}
}
get_currency_balance
Get currency balance information
uuosapi.get_currency_balance('eosio.token', 'eosio.saving' ,'EOS')
get_required_keys
Returns the required keys needed to sign a transaction
get_currency_stats
Get token’s information
uuosapi.get_currency_stats('eosio.token', 'EOS')
{
"EOS": {
"supply": "1010853656.0071 EOS",
"max_supply": "10000000000.0000 EOS",
"issuer": "eosio"
}
}
get_producers
Get block producers’ information
{
"rows": [
{
"owner": "eoshuobipool",
"total_votes": "912780250023381248.00000000000000000",
"producer_key": "EOS5XKswW26cR5VQeDGwgNb5aixv1AMcKkdDNrC59KzNSBfnH6TR7",
"is_active": 1,
"url": "http://eoshuobipool.com",
"unpaid_blocks": 2508,
"last_claim_time": "2019-05-09T00:29:02.000",
"location": 0
},
{
"owner": "starteosiobp",
"total_votes": "888420867709618944.00000000000000000",
"producer_key": "EOS4wZZXm994byKANLuwHD6tV3R3Mu3ktc41aSVXCBaGnXJZJ4pwF",
"is_active": 1,
"url": "https://www.starteos.io",
"unpaid_blocks": 5415,
"last_claim_time": "2019-05-08T15:58:09.000",
"location": 156
}
],
"total_producer_vote_weight": "47230651279257329664.00000000000000000",
"more": "eoslaomaocom"
}
uuosapi.get_producers(True, "", 2)
push_block
push_transaction
Send transaction
from uuoskit import uuosapi
from uuoskit import wallet
#wallet.unlock('testwallet', 'YOUR WALLET PASSWORD')
args = {"from": 'helloworld12',
"to": 'hello',
"quantity": '0.0001 EOS',
"memo": 'hello,world'
}
action = ['eosio.token', 'transfer', args, {'helloworld12':'active'}]
reference_block_id = uuosapi.get_info().last_irreversible_block_id
trx = uuosapi.gen_transaction([action], 120, reference_block_id)
public_keys = ['EOS4uFSpSqLovSD7cB7XgAkGxnAja3zASnQwuMjoQwP3cwyhdNFdX']
info = uuosapi.get_info()
trx = wallet.sign_transaction(trx, public_keys, info.chain_id)
trx = uuosapi.pack_transaction(trx, 0)
uuosapi.push_transaction(trx)
push_transactions
Pushes multiple transactions
from uuoskit import uuosapi
from uuoskit import wallet
#wallet.unlock('YOUR WALLET NAME', 'YOUR WALLET PASSWORD')
args1 = {"from": 'helloworld12',
"to": 'eosio',
"quantity": '0.0001 EOS',
"memo": 'hello,world'
}
action1 = ['eosio.token', 'transfer', args1, {'helloworld12':'active'}]
args2 = {"from": 'helloworld12',
"to": 'eosio.token',
"quantity": '0.0001 EOS',
"memo": 'hello,world'
}
action2 = ['eosio.token', 'transfer', args2, {'helloworld12':'active'}]
r = uuosapi.push_transactions([[action1, action2]])
get_actions
Returns account’s actions list
pos and offset mean: Get the “offset” Actions from the first “pos” record
uuosapi.get_actions('eosio.token', 0, 1)
{
"actions": [],
"last_irreversible_block": 1001186
}
get_transaction
Returns transaction details
uuosapi.get_transaction(id)
get_key_accounts
Returns the account corresponding to the public key
uuosapi.get_key_accounts(public_key)
gen_transaction
Create an unsigned transaction
reference_block_id = uuosapi.get_info().last_irreversible_block_id
uuosapi.gen_transaction([['hello', 'sayhello', b'', {'hello':'active'}]], 60, reference_block_id)