{"id":18769419,"url":"https://github.com/learnforpractice/pyeos","last_synced_at":"2025-07-23T16:08:01.386Z","repository":{"id":121688162,"uuid":"106552809","full_name":"learnforpractice/pyeos","owner":"learnforpractice","description":"A Universal Smart Contract Platform","archived":false,"fork":false,"pushed_at":"2022-11-18T01:07:12.000Z","size":131514,"stargazers_count":132,"open_issues_count":0,"forks_count":37,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-13T07:52:01.231Z","etag":null,"topics":["eos","ethereum","python"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/learnforpractice.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-10-11T12:43:28.000Z","updated_at":"2024-11-28T14:34:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"65e9c1fb-0b86-46e9-bb60-eee7e2d112de","html_url":"https://github.com/learnforpractice/pyeos","commit_stats":null,"previous_names":[],"tags_count":78,"template":false,"template_full_name":null,"purl":"pkg:github/learnforpractice/pyeos","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnforpractice%2Fpyeos","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnforpractice%2Fpyeos/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnforpractice%2Fpyeos/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnforpractice%2Fpyeos/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/learnforpractice","download_url":"https://codeload.github.com/learnforpractice/pyeos/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnforpractice%2Fpyeos/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266708513,"owners_count":23971944,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eos","ethereum","python"],"created_at":"2024-11-07T19:15:48.695Z","updated_at":"2025-07-23T16:08:01.367Z","avatar_url":"https://github.com/learnforpractice.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"A Self Evolving Universal Smart Contract Platform Base on The Development of EOSIO \n# Table of contents\n1. [Building PyEos](#buildingpyeos)\n\n2. [Smart Contract Development](#smartcontractdevelopment)\n\n   2.1 [Python Smart Contract Development](#pythonsmartcontractdevelopment)\n\n   2.2 [Ethereum Smart Contract Development](#ethereumsmartcontractdevelopment)\n\n   2.3 [Lua Smart Contract Development](#luasmartcontractdevelopment)\n\n   2.4 [Java Smart Contract Development](#javasmartcontractdevelopment)\n\n3. [Debugging With C++ Smart Contract](#smartcontractdebuggingcplusplus)\n\n4. [Debugging With Python Smart Contract](#smartcontractdebuggingpython)\n\n5. [PyEos API overview](#pyeosapioverview)\n\n\u003ca name=\"buildingPyEos\"\u003e\u003c/a\u003e\n\n# Building PyEos\n\n## Downloading Source Code\n\n```bash\ngit clone https://www.github.com/learnforpractice/pyeos\ncd pyeos\ngit submodule update --init --recursive\n```\n\n## Installing dependencies (Ubuntu)\n\n```\nsudo apt-get install libleveldb-dev\nsudo apt-get install libreadline-dev\n```\n\n\n## Installing dependencies (Centos)\n\n```\nsudo yum install leveldb-devel\nsudo yum install readline-devel\nsudo yum install libffi-devel\n```\n\n## Installing dependencies (macOS)\n\n```\nbrew install leveldb\nbrew install readline\n```\n\n## Installing JDK 10 or above (Optional)\nFor those who want to try Java Smart Contract, please update JDK to version 10 or above, then export JAVA_HOME to the root  directory of JDK install directory.\n\n```\nexport JAVA_HOME=\u003cdirectory of jdk\u003e\n```\n\nIf you have earlier JDK installed and JAVA_HOME is not empty and you don't want to try Java smart contract, please \nempty JAVA_HOME with the following command before building:\n\n```\nexport JAVA_HOME=\n```\n\n\n## Building\n\n```bash\n./eosio_build.sh\n```\n\n\u003ca name=\"smartcontractdevelopment\"\u003e\u003c/a\u003e\n\n# Smart Contract Development\n\n\u003ca name=\"pythonsmartcontractdevelopment\"\u003e\u003c/a\u003e\n\n### Python Smart Contract Development\n\n#### Running PyEos\n\nOpen a terminal, cd to [PROJECT_DIR]/build/program, run the following command\n\n```\n./pyeos/pyeos --manual-gen-block --debug -i  --contracts-console\n```\n\nIf this is the first time you start PyEos, PyEos will create a testing wallet for you, which placed in data-dir/mywallet.wallet, and then console will print the wallet password as below:\n\n```\nwallet password: PW5JWE5g6RZ7Fyr2kmCphDqZo4uivdeGpUpndgFZ52rsduhtf9PRJ\n```\n\nSince it's for testing only, password will save to data-dir/data.pkl, So next time you start pyeos for testing, pyeos will unlock wallet for you.\n\nAlso PyEos will import three private keys to the wallet, which is useful for testing.\n\n```\n'5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3',\n'5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s',\n'5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB'\n```\n\nKeep in mind that these private keys should never be used in real account, otherwise you may lose all of your crypto property in the account.\n\nBeside that, PyEos will create four important accounts for you:\n\n```\neosio.bios, eosio.msig, eosio.system, eosio.token\n```\n\nand publish their smart contract on testnet. \n\nAlthough the above steps will never happen in the real world, but it's really provide a great convenience for testing smart contract. Thus save a lot of your precious time and make the development more efficient.\n\n#### Generating source code with sketch tool\n\nRun the following command in PyEos console,\n\n```\nsketch.create('hello', 'helloworld', 'py')\n```\n\nThat will create a helloworld directory under your current directory with hello as the testing account name. There are three file generated in the directory:\n\n```\nhelloworld.py\nhelloworld.abi\nt.py\n```\n\nWhich helloworld.py is the Python smart contract source code, helloworld.abi is the ABI(Application Binary Interface) file for smart contract, t.py contains code for testing smart contract.\n\nIn addition, sketch can also create a wasm smart contract project for you, just type the following code in PyEos console, and the testing process has no difference with Python smart contract.\n\n```\nsketch.create('helloworld', 'helloworld', 'cpp')\n```\n\n#### Testing\n\n\nNow it's time to run your helloworld smart contract program. Type or copy the following command to the PyEos console:\n\n```python\nfrom helloworld import t\nt.test()\n```\n\nYou will see the following output on console in green words:\n\n```\n3289633ms thread-1   mpeoslib.cpp:63               print                ] hello,world\n```\n\nCongratulations, you have successfully run your first Python smart contract.\n\nNow you can open helloworld.py for coding. Once it's done, just run t.test() again, \nthere is no need to run other command to publish your testing smart contract, the smart contract will be automatically\nrepublish to the testnet if it's been changed during the running of t.test(). You can also edit the testing code in t.py for testing your smart contract. Once it's done, just run t.test() again, there is no need to run reload(t), PyEos will do the magic for you. That also works at the situation of adding a new function in test. \n\n\u003ca name=\"ethereumsmartcontractdevelopment\"\u003e\u003c/a\u003e\n\n## Ethereum Smart Contract Development\nPlease see the example in pyeos/programs/pyeos/tests/evm/evm\n\n\u003ca name=\"luasmartcontractdevelopment\"\u003e\u003c/a\u003e\n\n## Lua Smart Contract Development\n\nPlease see the example in pyeos/programs/pyeos/tests/lua/hello\n\n\u003ca name=\"javasmartcontractdevelopment\"\u003e\u003c/a\u003e\n\n## Java Smart Contract Development\nPlease see the example in pyeos/programs/pyeos/tests/java/hello\n\nReminder: For these who want to try Java Smart Contract, please update JDK to version 10 or above,\nand then set JAVA_HOME to the appropriate JDK root directory\n\n\u003ca name=\"smartcontractdebuggingcplusplus\"\u003e\u003c/a\u003e\n\n# Debugging With C++ Smart Contract\n\nOn Eos, C++ Smart Contract code is compiled to WebAssembly bytecode, that makes debugging C++ Smart Contract suffer. Fortunately now it's able to compile C++ Smart Contract to a shared library, that makes debugging a C++ Smart Contract as easy as debugging a normal C++ project. \n\nThere is a short video on youtube for quick start:\n\n[![Debugging](programs/pyeos/debugging/C++debugging.png?raw=true)](http://www.youtube.com/watch?v=7XPgnbjsXkE \"Debugging C++ Smart Contract\")\n\n\nTo be brief, here are the steps about debugging a C++ Smart Contract:\n\n### 1. Open pyeos project in Visual Studio Code\n\n### 2. Edit CMAKE_BUILD_TYPE and BUILD_DIR in eosio_build.sh\n\n```\n    BUILD_DIR=\"${PWD}/build-debug\"\n    CMAKE_BUILD_TYPE=Debug\n```\n\n### 3. Build pyeos in VSC terminal\n\n```\n./eosio_build.sh\n```\n\n### 4.Configure debug in Visual Studio Code\n```\n      {\n         \"name\": \"(lldb) Attach pyeos\",\n         \"type\": \"cppdbg\",\n         \"request\": \"attach\",\n         \"program\": \"${workspaceFolder}/build-debug/programs/pyeos/pyeos\",\n         \"processId\": \"${command:pickProcess}\",\n         \"MIMode\": \"lldb\"\n      }\n```\n\n### 5. Launch pyeos\n\n```\n./pyeos/pyeos --manual-gen-block --debug -i  --contracts-console\n```\n\n### 6. Attach to pyeos\n\n### 7. Create C++ Smart Contract test code.\n\n```python\nsketch.create('hello', 'helloworld', 'cpp')\n```\n\n### 8. Set breakpoint in test code\n\n### 9. Testing\n```\nfrom helloworld import t\nt.debug()\n```\n\n\u003ca name=\"smartcontractdebuggingpython\"\u003e\u003c/a\u003e\n\n# Python Smart Contract Debugging\n\nThere is a short video on youtube about Python Smart Contract for quick start:\n\n[![Debugging](programs/pyeos/debugging/PythonDebugging.png?raw=true)](http://www.youtube.com/watch?v=eTwx-VTxhfo \"Debugging C++ Smart Contract\")\n\n\nThe following steps show how to debug smart contract under programs/pyeos/contracts/hello\n\n#### 1. Launch PyEos\n```\n./pyeos/pyeos --manual-gen-block --debug -i  --contracts-console\n```\n\n#### 2. Set debug contract\n```\ndebug.set_debug_contract('hello', '../../programs/pyeos/contracts/hello/hello.py')\n```\n\n#### 3. Start ptvsd debugger\n```python\nimport ptvsd\nptvsd.enable_attach(\"12345\", address = ('127.0.0.1', 3000))\nptvsd.wait_for_attach()\n```\n\n#### 4. Attach to ptvsd debugger in Visual Studio Code\nHere is the debug setting:\n\n```javascript\n   {\n      \"name\": \"python Attach (Remote Debug)\",\n      \"type\": \"python\",\n      \"request\": \"attach\",\n      \"localRoot\": \"${workspaceFolder}\",\n      \"remoteRoot\": \"${workspaceFolder}\",\n      \"port\": 3000,\n      \"secret\": \"12345\",\n      \"host\": \"localhost\"\n   },\n```\n\n\n#### 5. Set breakpoint in hello.py\n\n#### 6. Debugging\n```\nfrom hello import t\nt.test()\n```\n\nEnjoy it!\n\n\u003ca name=\"pyeosapioverview\"\u003e\u003c/a\u003e\n\n# PyEos API overview\n\n#### eosapi.get_info\n```python\ninfo = eosapi.get_info()\ninfo\n```\n\n```javascript\n{\n    \"server_version\": \"00000000\",\n    \"head_block_num\": 127,\n    \"last_irreversible_block_num\": 126,\n    \"head_block_id\": \"0000007fbd1ff82f29668dfa89d927a0510c657cce292c033496ccaacf04c12a\",\n    \"head_block_time\": \"2018-05-06T07:57:44\",\n    \"head_block_producer\": \"eosio\"\n}\n```\n\n```python\ninfo.head_block_time\n```\n```\n'2017-09-23T15:16:18'\n```\n\n```python\ninfo.head_block_num\n```\n\n```\n18624\n```\n\n#### wallet.create\n\nPyEos will create a testing wallet for you the first time you start it, but you can also create other wallet wit wallet.create API\n\n```python\npsw = wallet.create('mywallet2')\npsw\n```\n\n```\n'PW5JCWXaGkA15s6th6AWCabHewuGASAtrUJjTWoL1Ybx6sG9QzrSb'\n```\nYou can see your wallet now. The * behind mywallet means the wallet is unlocked.\n\n```\nwallet.list_wallets()\n```\n\n```\n['mywallet *']\n```\n#### wallet.open wallet.unlock\n\n```\nwallet.open('mywallet2')\nwallet.unlock('mywallet2','PW5JCWXaGkA15s6th6AWCabHewuGASAtrUJjTWoL1Ybx6sG9QzrSb')\n```\n\n#### wallet.import_key\nLet's import the private key of inita. Please refer to [Setting up a wallet and importing account key](https://github.com/learnforpractice/pyeos#setting-up-a-wallet-and-importing-account-key) for more information.\n\n```\nwallet.import_key('mywallet2','5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3')\n```\n\n#### eosapi.create_key\n\nCreate owner key\n\n```python\neosapi.create_key()\n```\n\n```javascript\n{'public': 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst', 'private': '5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s'}\n```\n\nCreate active key\n\n```python\neosapi.create_key()\n```\n\n```javascript\n{'public': 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL', 'private': '5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB'}\n```\n\nImport owner key\n\n```python\nwallet.import_key('mywallet2','5JEcwbckBCdmji5j8ZoMHLEUS8TqQiqBG1DRx1X9DN124GUok9s')\n```\n\nImport active key\n\n```python\nwallet.import_key('mywallet2','5JbDP55GXN7MLcNYKCnJtfKi9aD2HvHAdY7g8m67zFTAFkY1uBB')\n```\n\n#### eosapi.create_account\n\n```python\nkey1 = 'EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst'\nkey2 = 'EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL'\neosapi.create_account('eosio', 'currency', key1, key2)\n\n```\n\n#### eosapi.get_account\n\n```\neosapi.get_account('currency')\n```\n\n```javascript\n{\n    \"account_name\": \"currency\",\n    \"head_block_num\": 43,\n    \"head_block_time\": \"2018-07-11T09:01:00.500\",\n    \"privileged\": false,\n    \"last_code_update\": \"1970-01-01T00:00:00.000\",\n    \"created\": \"2018-07-11T09:01:00.500\",\n    \"ram_quota\": 65206,\n    \"net_weight\": 10050,\n    \"cpu_weight\": 10050,\n    \"net_limit\": {\n        \"used\": 0,\n        \"available\": 62988768000,\n        \"max\": 62988768000\n    },\n    \"cpu_limit\": {\n        \"used\": 0,\n        \"available\": 12013286400,\n        \"max\": 12013286400\n    },\n    \"ram_usage\": 3446,\n    \"permissions\": [\n        {\n            \"perm_name\": \"active\",\n            \"parent\": \"owner\",\n            \"required_auth\": {\n                \"threshold\": 1,\n                \"keys\": [\n                    {\n                        \"key\": \"EOS61MgZLN7Frbc2J7giU7JdYjy2TqnfWFjZuLXvpHJoKzWAj7Nst\",\n                        \"weight\": 1\n                    }\n                ],\n                \"accounts\": [],\n                \"waits\": []\n            }\n        },\n        {\n            \"perm_name\": \"owner\",\n            \"parent\": \"\",\n            \"required_auth\": {\n                \"threshold\": 1,\n                \"keys\": [\n                    {\n                        \"key\": \"EOS5JuNfuZPATy8oPz9KMZV2asKf9m8fb2bSzftvhW55FKQFakzFL\",\n                        \"weight\": 1\n                    }\n                ],\n                \"accounts\": [],\n                \"waits\": []\n            }\n        }\n    ],\n    \"total_resources\": {\n        \"owner\": \"currency\",\n        \"net_weight\": \"1.0050 EOS\",\n        \"cpu_weight\": \"1.0050 EOS\",\n        \"ram_bytes\": 65206\n    },\n    \"self_delegated_bandwidth\": {\n        \"from\": \"currency\",\n        \"to\": \"currency\",\n        \"net_weight\": \"1.0050 EOS\",\n        \"cpu_weight\": \"1.0050 EOS\"\n    },\n    \"refund_request\": null,\n    \"voter_info\": {\n        \"owner\": \"currency\",\n        \"proxy\": \"\",\n        \"producers\": [],\n        \"staked\": 20100,\n        \"last_vote_weight\": 0.0,\n        \"proxied_vote_weight\": 0.0,\n        \"is_proxy\": 0\n    }\n}\n```\n\n#### eosapi.get_balance\n```\neosapi.get_balance('eosio')\n```\nreturn:\n```\n9999999961645.494\n```\n\n#### eosapi.transfer\n```\neosapi.transfer('eosio', 'currency', 100.6666)\n```\nreturn:\n```\nTrue\n```\n\n#### eosapi.push_action\n```python\neosapi.get_balance('eosio')\neosapi.get_balance('currency')\nargs = {\"from\":'eosio', \"to\":'currency', \"quantity\":'100.6666 EOS', \"memo\":'hello'}\nr = eosapi.push_action('eosio.token', 'transfer', args, {'eosio':'active'})\neosapi.get_balance('eosio')\neosapi.get_balance('currency')\n```\n\n```python\n\u003e\u003e\u003e eosapi.get_balance('eosio')\n9999999961142.162\n\u003e\u003e\u003e eosapi.get_balance('currency')\n513.9996\n\u003e\u003e\u003e args = {\"from\":'eosio', \"to\":'currency', \"quantity\":'100.6666 EOS', \"memo\":'hello'}\n\u003e\u003e\u003e r = eosapi.push_action('eosio.token', 'transfer', args, {'eosio':'active'})\n\u003e\u003e\u003e eosapi.get_balance('eosio')\n9999999961041.496\n\u003e\u003e\u003e eosapi.get_balance('currency')\n614.6662\n```\n\nthe above code is what eosapi.transfer does.\n\n#### eosapi.push_actions\n```python\nr = get_balance('currency')\nprint(r)\nargs = {\"from\":'eosio', \"to\":'currency', \"quantity\":'100.6666 EOS', \"memo\":'hello'}\nargs = eosapi.pack_args('eosio.token', 'transfer', args)\nact = ['eosio.token', 'transfer', {'eosio':'active'}, args]\nr = eosapi.push_actions([act, act])\nr = eosapi.get_balance('currency')\nprint(r)\n```\n\n```python\n\u003e\u003e\u003e r = get_balance('currency')\n\u003e\u003e\u003e print(r)\n211.9998\n\u003e\u003e\u003e args = {\"from\":'eosio', \"to\":'currency', \"quantity\":'100.6666 EOS', \"memo\":'hello'}\n\u003e\u003e\u003e args = eosapi.pack_args('eosio.token', 'transfer', args)\n\u003e\u003e\u003e act = ['eosio.token', 'transfer', {'eosio':'active'}, args]\n\u003e\u003e\u003e r = eosapi.push_actions([act, act])\n\u003e\u003e\u003e r = eosapi.get_balance('currency')\n\u003e\u003e\u003e print(r)\n413.333\n```\n\n\n#### eosapi.get_transaction\n\n```python\nr = eosapi.get_transaction('f6c43148dfac54105031fbaf966958d36309dd94e665c506eb2769e43febedba')\nr\nr.transaction.signatures\nr.transaction.packed_trx\n```\n\n#### eosapi.set_contract\nPublish python smart contract to the blockchain\n\n```python\nr = eosapi.set_contract('hello','../../programs/pyeos/contracts/hello/hello.py','../../contracts/hello/hello.abi',1)\nr\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearnforpractice%2Fpyeos","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearnforpractice%2Fpyeos","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearnforpractice%2Fpyeos/lists"}