Python Toolkit for Eos
python3 -m pip install https://github.com/learnforpractice/pyeoskit/releases/download/v0.3.0/pyeoskit-0.3.0-cp36-cp36m-macosx_10_9_x86_64.whl
python3 -m pip install https://github.com/learnforpractice/pyeoskit/releases/download/v0.3.0/pyeoskit-0.3.0-cp36-cp36m-linux_x86_64.whl
python -m pip install https://github.com/learnforpractice/pyeoskit/releases/download/v0.3.0/pyeoskit-0.3.0-cp36-cp36m-win_amd64.whl
python3 -m pip install scikit-build
python3 -m pip install cython==0.28.5
https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=Community&rel=15
https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk
https://www.python.org/downloads/
python3 -m pip install scikit-build
python3 -m pip install cython==0.28.5
git clone https://www.github.com/learnforpractice/pyeoskit
cd pyeoskit
git submodule update --init --recursive
set PATH=%PATH%;"C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64"
python setup.py sdist bdist_wheel -G "NMake Makefiles"
CC=clang CXX=clang++ python3 setup.py sdist bdist_wheel --plat-name macosx-10.9-x86_64
CC=clang CXX=clang++ python3 setup.py sdist bdist_wheel -- -DCMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/polly/clang-fpic.cmake -- -j7
CC=gcc CXX=g++ python3 setup.py sdist bdist_wheel -- -DCMAKE_TOOLCHAIN_FILE=$(pwd)/cmake/polly/gcc-pic.cmake -- -j7
ls dist
python3 -m pip install dist/pyeoskit-[SUFFIX].whl
from pyeoskit import eosapi
from pyeoskit import wallet
mywallet = 'mywallet'
psw = wallet.create(mywallet)
print(psw)
#PW5JwNkkPH7Ji1KfNfKXc4NHYwtEsxAh471YSiUzctwj7kVCD4Bih
from pyeoskit import eosapi
from pyeoskit import wallet
psw = 'PW5JwNkkPH7Ji1KfNfKXc4NHYwtEsxAh471YSiUzctwj7kVCD4Bih'
wallet.unlock(mywallet, psw)
#import active key of account hello
wallet.import_key(mywallet, '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB')
args = {"from": 'hello',
"to": 'eosio',
"quantity": '0.0001 EOS',
"memo": 'hello,world'
}
eosapi.push_action('eosio.token', 'transfer', args, {'hello':'active'})
from pyeoskit import eosapi
from pyeoskit import wallet
import os
if os.path.exists('mywallet.wallet'):
os.remove('mywallet.wallet')
psw = wallet.create('mywallet')
wallet.unlock('mywallet', psw)
wallet.import_key('mywallet', '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB')
code = b'''
import db
from eoslib import N, read_action, send_inline, transfer_inline
def sayHello():
n = N('hello')
id = N('name')
name = read_action()
print('hello', name)
code = n
scope = n
table = n
payer = n
itr = db.find_i64(code, scope, table, id)
if itr >= 0: # value exist, update it
old_name = db.get_i64(itr)
print('hello,', old_name)
db.update_i64(itr, payer, name)
else:
db.store_i64(scope, table, payer, id, name)
def apply(receiver, code, action):
if action == N('sayhello'):
sayHello()
'''
abi = b'''
{
"version": "eosio::abi/1.0",
"structs": [{
"name": "message",
"base": "",
"fields": [
{"name":"msg", "type":"string"}
]
}
],
"actions": [{
"name": "sayhello",
"type": "raw"
}
]
}
'''
eosapi.set_contract('hello', code, abi, 1)
eosapi.push_action('hello', 'sayhello', b'hello,world', {'hello':'active'})
More examples in Docs