Skip to main content

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!

Metadata

Release files for eth-fn 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eth-fn 0.1
File Size Uploaded
eth_fn-0.1.tar.gz 3.0 kB Details

Release files / eth_fn-0.1.tar.gz

Download URL eth_fn-0.1.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d03c87b4dc1ee792315209e08141f6764054803f8cbc31eac3294bb5daeceb50
BLAKE2b-256 checksum
How to use checksums
9b315f6ac10c7730b53cb37326faa037faa0781b04d7bbb0f10f0cc19aeaa186
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page