Name | eth-fn JSON |
Version |
0.1
JSON |
| download |
home_page | https://github.com/kernel1983/eth-fn |
Summary | eth_fn: Simple Python utilities for web3py to call ETH contract without ABI |
upload_time | 2025-01-08 19:08:08 |
maintainer | None |
docs_url | None |
author | 0xKJ |
requires_python | <4,>=3.8 |
license | MIT |
keywords |
ethereum
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# eth-fn
In web3py, to call a function od a smart contract, it requires to include long ABI information.
https://web3py.readthedocs.io/en/stable/web3.contract.html
Instead, we can do similiar with `eth_fn`:
import web3
import eth_account
from eth_fn import eth_fn
a = eth_account.Account.from_key('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80')
print(a.address)
PROVIDER_HOST = 'http://127.0.0.1:8545'
w3 = web3.Web3(web3.Web3.HTTPProvider(PROVIDER_HOST))
transaction = {
'from': a.address,
'to': '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
'value': 0,
'nonce': w3.eth.get_transaction_count(a.address),
'data': eth_fn('transfer(address,uint256)', ['0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512', 10**19]),
'gas': 100000,
'maxFeePerGas': 1000000000,
'maxPriorityFeePerGas': 0,
'chainId': 31337
}
signed = w3.eth.account.sign_transaction(transaction, a.key)
tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)
To install, simple type:
pip install eth-fn
Hope you like it!
Raw data
{
"_id": null,
"home_page": "https://github.com/kernel1983/eth-fn",
"name": "eth-fn",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.8",
"maintainer_email": null,
"keywords": "ethereum",
"author": "0xKJ",
"author_email": "kernel1983@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9b/31/5f6ac10c7730b53cb37326faa037faa0781b04d7bbb0f10f0cc19aeaa186/eth_fn-0.1.tar.gz",
"platform": null,
"description": "# eth-fn\n\nIn web3py, to call a function od a smart contract, it requires to include long ABI information.\n\nhttps://web3py.readthedocs.io/en/stable/web3.contract.html\n\nInstead, we can do similiar with `eth_fn`:\n\n import web3\n import eth_account\n\n from eth_fn import eth_fn\n\n a = eth_account.Account.from_key('0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80')\n print(a.address)\n\n PROVIDER_HOST = 'http://127.0.0.1:8545'\n w3 = web3.Web3(web3.Web3.HTTPProvider(PROVIDER_HOST))\n\n transaction = {\n 'from': a.address,\n 'to': '0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',\n 'value': 0,\n 'nonce': w3.eth.get_transaction_count(a.address),\n 'data': eth_fn('transfer(address,uint256)', ['0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512', 10**19]),\n 'gas': 100000,\n 'maxFeePerGas': 1000000000,\n 'maxPriorityFeePerGas': 0,\n 'chainId': 31337\n }\n\n signed = w3.eth.account.sign_transaction(transaction, a.key)\n tx_hash = w3.eth.send_raw_transaction(signed.rawTransaction)\n\nTo install, simple type:\n\n pip install eth-fn\n\nHope you like it!\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "eth_fn: Simple Python utilities for web3py to call ETH contract without ABI",
"version": "0.1",
"project_urls": {
"Homepage": "https://github.com/kernel1983/eth-fn"
},
"split_keywords": [
"ethereum"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9b315f6ac10c7730b53cb37326faa037faa0781b04d7bbb0f10f0cc19aeaa186",
"md5": "766e975961bd8d2dac7feda7ec296d0c",
"sha256": "d03c87b4dc1ee792315209e08141f6764054803f8cbc31eac3294bb5daeceb50"
},
"downloads": -1,
"filename": "eth_fn-0.1.tar.gz",
"has_sig": false,
"md5_digest": "766e975961bd8d2dac7feda7ec296d0c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.8",
"size": 2965,
"upload_time": "2025-01-08T19:08:08",
"upload_time_iso_8601": "2025-01-08T19:08:08.910114Z",
"url": "https://files.pythonhosted.org/packages/9b/31/5f6ac10c7730b53cb37326faa037faa0781b04d7bbb0f10f0cc19aeaa186/eth_fn-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-08 19:08:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kernel1983",
"github_project": "eth-fn",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "eth-fn"
}