eth_fn: Simple Python utilities for web3py to call ETH contract without ABI
Project description
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!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
eth_fn-0.1.tar.gz
(3.0 kB
view details)
File details
Details for the file eth_fn-0.1.tar.gz.
File metadata
- Download URL: eth_fn-0.1.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d03c87b4dc1ee792315209e08141f6764054803f8cbc31eac3294bb5daeceb50
|
|
| MD5 |
766e975961bd8d2dac7feda7ec296d0c
|
|
| BLAKE2b-256 |
9b315f6ac10c7730b53cb37326faa037faa0781b04d7bbb0f10f0cc19aeaa186
|