Interactive Python for Eos
What Is IPyEos
- IPyEos is a Smart Contracts test framework for Eos
- IPyEos is a Python binding for Eos
Installation
python3 -m pip install ipyeos
on the macOS platform, you may need to install gmp and zstd if you don't install them.
brew reinstall gmp
brew reinstall zstd
If your platform is Windows or MacOSX M1/M2, you also need to download an image that includes the ipyeos tool:
docker pull ghcr.io/uuosio/ipyeos:latest
If you have not installed the ipyeos image in Docker, then the ipyeos image will be automatically downloaded the first time you run ipyeos or eosdebugger.
On macOS, the recommended software for installing and running Docker is OrbStack. For other platforms, you can use Docker Desktop.
Test Examples
Example 1:
#test.py
import os
from ipyeos.chaintester import ChainTester
chaintester.chain_config['contracts_console'] = True
def test_example():
t = ChainTester(True)
with open('./hello/build/hello/hello.wasm', 'rb') as f:
code = f.read()
with open('./hello/build/hello/hello.abi', 'rb') as f:
abi = f.read()
t.deploy_contract('hello', code, abi)
t.produce_block()
t.push_action('hello', 'hi', {'nm': 'alice'}, {'hello': 'active'})
t.produce_block()
Test:
ipyeos -m pytest -x -s tests/test.py
Restore from snapshot Example
def test_snapshot():
# data_name = './data'
# snapshot_dir = './snapshot-2023-06-18-01-eos-v6-0315729695.bin'
# state_size = 32*1024*1024*1024
if os.path.exists('./data/ddd'):
shutil.rmtree('./data/ddd')
state_size = 10*1024*1024
data_name = './data'
snapshot_dir = './data/snapshot-0000001ba25b3b5af4ba6cacecb68ef4238a50bb7134e56fe985b4355fbf7488.bin'
t = ChainTester(True, data_dir=os.path.join(data_name, 'ddd'), config_dir=os.path.join(data_name, 'cd'), state_size=state_size, snapshot_dir=snapshot_dir)
Accessing Database Object Example
def test_database_object():
# data_name = './data'
# snapshot_dir = './snapshot-2023-06-18-01-eos-v6-0315729695.bin'
# state_size = 32*1024*1024*1024
if os.path.exists('./data/ddd'):
shutil.rmtree('./data/ddd')
state_size = 10*1024*1024
data_name = './data'
snapshot_dir = './data/snapshot-0000001ba25b3b5af4ba6cacecb68ef4238a50bb7134e56fe985b4355fbf7488.bin'
# {'private': '5K3x5DPEbocfZSG8XD3RiyJAfPFH5Bd9ED15wtdEMbqzXCLPbma',
# 'public': 'EOS5K93aPtTdov2zWDqYxVcMQ4GBT1hyEpED8tjzPuLsf31tPySNY'}
# must call set_debug_producer_key and import_producer_key before create ChainTester
eos.set_debug_producer_key('EOS5K93aPtTdov2zWDqYxVcMQ4GBT1hyEpED8tjzPuLsf31tPySNY')
chaintester.import_producer_key('5K3x5DPEbocfZSG8XD3RiyJAfPFH5Bd9ED15wtdEMbqzXCLPbma')
t = ChainTester(True, data_dir=os.path.join(data_name, 'ddd'), config_dir=os.path.join(data_name, 'cd'), state_size=state_size, snapshot_dir=snapshot_dir)
logger.info("+++++producer keys: %s", t.chain.get_producer_public_keys())
t.produce_block()
logger.info("+++++++%s", t.api.get_info())
idx = PermissionObjectIndex(t.db)
perm = idx.find_by_owner('eosio.token', 'active')
print(perm)
# Private key: 5JBW9jddvqHY7inGEK2qWbGLYKeqm32NDYL3fLdYgMjnWxRjXLF
# Public key: EOS6hM1U89jbHWyX8ArHttFzoGe21y7ehXvtN5q7GbDxYEa9NFXH2
t.import_key('5JBW9jddvqHY7inGEK2qWbGLYKeqm32NDYL3fLdYgMjnWxRjXLF')
keys = [KeyWeight(PublicKey.from_base58('EOS6hM1U89jbHWyX8ArHttFzoGe21y7ehXvtN5q7GbDxYEa9NFXH2'), 1)]
perm.auth = Authority(1, keys, [], [])
ret = idx.modify(perm)
print('modify_by_id return:', ret)
idx = PermissionObjectIndex(t.db)
perm = idx.find_by_owner('eosio.token', 'active')
print(perm)
Push Block Example:
def test_push_block():
if os.path.exists('./data/ddd'):
shutil.rmtree('./data/ddd')
state_size = 10*1024*1024
data_name = './data'
snapshot_dir = './data/push_block/snapshot-0000003b83662343c208e965654f4d906ed7fad0372e13c246981cd076d379bb.bin'
t = ChainTester(True, data_dir=os.path.join(data_name, 'ddd'), config_dir=os.path.join(data_name, 'cd'), state_size=state_size, snapshot_dir=snapshot_dir)
t.free()
snapshot_dir = ''
t = ChainTester(True, data_dir=os.path.join(data_name, 'ddd'), config_dir=os.path.join(data_name, 'cd'), state_size=state_size, snapshot_dir=snapshot_dir)
t.chain.abort_block()
info = t.api.get_info()
head_block_num = info['head_block_num']
log = BlockLog('./data/push_block/blocks')
logger.info("%s %s", head_block_num, log.head_block_num())
num_count = log.head_block_num() - head_block_num
for block_num in range(head_block_num+1, head_block_num+num_count+1):
t.chain.push_block(log, block_num)
Building
To build this project, please follow the steps below:
- Clone the source code from the repository:
git clone https://github.com/uuosio/ipyeos --branch main --recursive
-
Build the forked leap source code under the
leapdirectory by following the instructions in the build-and-install-from-source documentation. -
Build the Python release package:
cd ipyeos
./build.sh
- Install the Python package
python3 -m pip install dist/pyeos-0.4.9**.whl
Run a Node
eosnode
Run a Debugging Server
eosdebugger
Testing
test example code
#test.py
import os
from ipyeos.chaintester import ChainTester
chaintester.chain_config['contracts_console'] = True
def test_example():
t = ChainTester(True)
with open('./hello/build/hello/hello.wasm', 'rb') as f:
code = f.read()
with open('./hello/build/hello/hello.abi', 'rb') as f:
abi = f.read()
t.deploy_contract('hello', code, abi)
t.produce_block()
t.push_action('hello', 'hi', {'nm': 'alice'}, {'hello': 'active'})
t.produce_block()
ipyeos -m pytest -x -s tests/test.py
Run a Testnet
ipyeos -m ipyeos eosnode --data-dir dd --config-dir cd -p eosio --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::producer_api_plugin -e --resource-monitor-space-threshold 99 --http-server-address 127.0.0.1:8889 --contracts-console --access-control-allow-origin="*" --wasm-runtime eos-vm-jit
Also, you can run a test node with eosnode command directly.
eosnode --data-dir dd --config-dir cd -p eosio --plugin eosio::producer_plugin --plugin eosio::chain_api_plugin --plugin eosio::producer_api_plugin -e --resource-monitor-space-threshold 99 --http-server-address 127.0.0.1:8889 --contracts-console --access-control-allow-origin="*" --wasm-runtime eos-vm-jit
Note
If you encounter the error message during running the above commands like Failed to load libpython3.7m.so!, try running the following command in your terminal:
export PYTHON_SHARED_LIB_PATH=path/to/libpython[.so|.dylib]
License
Metadata
Release files for ipyeos 0.4.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ipyeos-0.4.9.tar.gz | 1.1 MB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| ipyeos-0.4.9-cp311-cp311-manylinux_2_31_x86_64.whl | CPython 3.11 | CPython 3.11 | Linux glibc 2.31+ x86-64 | Details |
| ipyeos-0.4.9-cp311-cp311-macosx_10_15_x86_64.whl | CPython 3.11 | CPython 3.11 | macOS 10.15+ x86-64 | Details |
| ipyeos-0.4.9-cp310-cp310-manylinux_2_31_x86_64.whl | CPython 3.10 | CPython 3.10 | Linux glibc 2.31+ x86-64 | Details |
| ipyeos-0.4.9-cp310-cp310-macosx_10_15_x86_64.whl | CPython 3.10 | CPython 3.10 | macOS 10.15+ x86-64 | Details |
| ipyeos-0.4.9-cp39-cp39-manylinux_2_31_x86_64.whl | CPython 3.9 | CPython 3.9 | Linux glibc 2.31+ x86-64 | Details |
| ipyeos-0.4.9-cp39-cp39-macosx_10_15_x86_64.whl | CPython 3.9 | CPython 3.9 | macOS 10.15+ x86-64 | Details |
| ipyeos-0.4.9-cp38-cp38-manylinux_2_31_x86_64.whl | CPython 3.8 | CPython 3.8 | Linux glibc 2.31+ x86-64 | Details |
| ipyeos-0.4.9-cp38-cp38-macosx_10_15_x86_64.whl | CPython 3.8 | CPython 3.8 | macOS 10.15+ x86-64 | Details |
Total release size: 188.3 MB
Release files / ipyeos-0.4.9.tar.gz
| Download URL | ipyeos-0.4.9.tar.gz |
|---|---|
| Size | 1.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f62c883ff347a010c5a8154b12444a51c6c7337e7cb474bd384a67624a014867
|
|
BLAKE2b-256 checksum How to use checksums |
4577c99fc393b87fc3362d8e33f8cdf15bad1c11fad6b19f6327be13105a32a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp311-cp311-manylinux_2_31_x86_64.whl
| Download URL | ipyeos-0.4.9-cp311-cp311-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 34.4 MB |
| Tags | CPython 3.11 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
dd118c93786386f344cdc40b3f3d949071a1dc3a49b8a5ce8bbb5a951fe3c8b4
|
|
BLAKE2b-256 checksum How to use checksums |
efe49b4b278f681818a44527fdf29b382aab7d3522a880045899d6d5d8e0bfb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp311-cp311-macosx_10_15_x86_64.whl
| Download URL | ipyeos-0.4.9-cp311-cp311-macosx_10_15_x86_64.whl |
|---|---|
| Size | 12.4 MB |
| Tags | CPython 3.11 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
26448d76b1a316c0ffbdacdc01d5c61c54449ec7d04e2b1ffbaa8f978f2cb444
|
|
BLAKE2b-256 checksum How to use checksums |
bae05bb94c260c60e3acb32706bb96347ce90e801c3eb91bdd426367a63054d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp310-cp310-manylinux_2_31_x86_64.whl
| Download URL | ipyeos-0.4.9-cp310-cp310-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 34.4 MB |
| Tags | CPython 3.10 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
e1d93d6358bebb84bc2826dcc357c54d93abb0103b0cda7363ec15bb2637c805
|
|
BLAKE2b-256 checksum How to use checksums |
6664d03278262c0027fb07e4c495a19c34d20e01b276b453abf702ba0aa8e7f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp310-cp310-macosx_10_15_x86_64.whl
| Download URL | ipyeos-0.4.9-cp310-cp310-macosx_10_15_x86_64.whl |
|---|---|
| Size | 12.4 MB |
| Tags | CPython 3.10 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
8e4f7b70b07d7531d22471080a02ec7cc2a979b3b9f3137a617b6271d42e34f3
|
|
BLAKE2b-256 checksum How to use checksums |
f82844d018111c9df2cd36e64c83760b613ba92f1ac98d3707ec083eff936c64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp39-cp39-manylinux_2_31_x86_64.whl
| Download URL | ipyeos-0.4.9-cp39-cp39-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 34.3 MB |
| Tags | CPython 3.9 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
cfa61c038801539c9bd0c68d8124948280e4c31789cca816ca0c2410f36b0a1c
|
|
BLAKE2b-256 checksum How to use checksums |
e7cea5759e5dadfbf28db2097ea03389e1d0a6056a6fd27dbde725edbdf2dd91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp39-cp39-macosx_10_15_x86_64.whl
| Download URL | ipyeos-0.4.9-cp39-cp39-macosx_10_15_x86_64.whl |
|---|---|
| Size | 12.4 MB |
| Tags | CPython 3.9 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
eebe3f5be166e6be2c99c55868e755b3e0442effea850eed4a509cc1d017f633
|
|
BLAKE2b-256 checksum How to use checksums |
9a32ab5a2791489f5e606960ee9992f6876bb925165a4f785aa6052c5d6cfb5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp38-cp38-manylinux_2_31_x86_64.whl
| Download URL | ipyeos-0.4.9-cp38-cp38-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 34.3 MB |
| Tags | CPython 3.8 Linux glibc 2.31+ x86-64 |
|
SHA-256 checksum How to use checksums |
f26360674a6cf9a95a4ffccd03b5566db5548900a63b006673a47f9d55430e60
|
|
BLAKE2b-256 checksum How to use checksums |
0787ac9a1774f05181049d2013ee1d4cc922110eaa37df4bab2a305704574275
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / ipyeos-0.4.9-cp38-cp38-macosx_10_15_x86_64.whl
| Download URL | ipyeos-0.4.9-cp38-cp38-macosx_10_15_x86_64.whl |
|---|---|
| Size | 12.4 MB |
| Tags | CPython 3.8 macOS 10.15+ x86-64 |
|
SHA-256 checksum How to use checksums |
1182775dc84649e9c7a27e491b49c2d44dd099ecb2971fac45eaf6ffa0a014cb
|
|
BLAKE2b-256 checksum How to use checksums |
662259dcbe0616d9c536dbe5d099766b23b520e68672c68e4e24533b13f69de6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for ipyeos 0.4.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.