Skip to main content

eth_transfer

Easily send transactions on the Ethereum blockchain and fine tune gas parameters.

Motivation

The Web3.py python library, Alchemy API, and a slew of other projects provide easy ways to send transactions (exchange of value between addresses). However, there is often a lot of guess work that goes into selecting the values affecting the total gas fee, such as the max priority fee per gas, the max fee per gas, and the maximum amount of gas the user is willing to be consumed for the transaction to succeed. The Etherum network can become very busy at certain times (i.e. days following the FTX bankruptcy) and thus gas fees become very large. User controls on gas on applications such as MetaMask are basic, and give vaugue time estimates when trying to save on gas fees.

This package intends to provide an easy to use and customizable object oriented way to send transactions that minimize gas fees according to your needs.

How to use

The use of this package requires you are able to connect to the Etherum blockchain using web3.py and also have an Etherscan account from which you can create an API key. Access to PRO Etherscan endpoints is not neeeded.

Installing web3

If you do not have the web3 package installed in your environment or virtual environment, follow the quickstart here.

If you do not have an Etherscan account, create one as well as an API key by following the Getting Started steps here.

Quickstart

You can install the eth_transfer package via pip

pip3 install eth_transfer

Sending a Transaction

After you have installed the package, create a Web3 instance using either a local or remote provider. Below, we use the Remote provider Infura.io as an example.

w3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/YOUR_PROJECT_ID"))

Instantiate an instance of the Tx class

address_1 = SENDING_ADDRESS
address_2 = RECEIVING_ADDRESS

transaction = Tx(w3, address_1, address_2, '0.100 ether', '55 gwei', '1 gwei')

Now, send the transaction

transaction.send_transaction()

Tracking Gas Prices

Instantiate an instance of the GasTracker class. This can be done one of two ways. Both ways are shown below

  • From variable with string of your API key
    etherscan_key = YOUR_ETHERSCAN_KEY
    gastracker = GasTracker.from_key(etherscan_key)
    
  • From env with your API Key
    fpath = FILEPATH_TO_ENV_WITH_API_KEY # e.g. '/Users/DeadBeef/Desktop/etherscan.env'
    key_name = ENV_API_KEY_NAME # e.g. 'API_KEY'
    gastracker = GasTracker.from_env(fpath, key_name)
    
  • Confirmation Times vs. Fee Per Gas

    gas_limit = 50000 # Note: minimum is 21,000 
    gastracker.plot_gas_price_confirmation_time(gas_limit)
    

    Sending a slow transaction

    Sometimes, you can wait for a transaction to be confirmed! If so, you might as well save ETH on it being confirmed. Note, the maximum fee per gas you are willing to pay must exceed the current base fee. This is taken care of for you.

    gastracker.get_safe_gas_price()
    

    Metadata

    Release files for eth-transfer 0.0.3

    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-transfer 0.0.3
    File Size Uploaded
    eth_transfer-0.0.3.tar.gz 9.0 kB Details

    Built distribution (wheel)

    Table of built distributions (wheels) for eth-transfer 0.0.3
    File Interpreter ABI Platform
    eth_transfer-0.0.3-py3-none-any.whl Python 3 none any Details

    Total release size: 18.1 kB

    Release files / eth_transfer-0.0.3.tar.gz

    Download URL eth_transfer-0.0.3.tar.gz
    Size 9.0 kB
    Tags Source
    SHA-256 checksum
    How to use checksums
    5e5dfbeaa70b0a1aa537de061080e6aaa85b2dd707adb82c02a521682c40b25e
    BLAKE2b-256 checksum
    How to use checksums
    0e1b4c24574b7dbd147041e09751283aef1adcc2942c3ef7337fa32bc8e54327
    Upload date
    Uploaded using Trusted Publishing?
    What is trusted publishing?
    No
    Uploaded via twine/4.0.1 CPython/3.10.6

    Release files / eth_transfer-0.0.3-py3-none-any.whl

    Download URL eth_transfer-0.0.3-py3-none-any.whl
    Size 9.1 kB
    Tags Python 3
    SHA-256 checksum
    How to use checksums
    b351d2dfde486ede1c708e3e3d6ec480c2c3c32f5661b193c78c2b621a082d75
    BLAKE2b-256 checksum
    How to use checksums
    5a36dfb042855c8f15c5116983460e463df8b9e08d4251c6bae84f05a729b583
    Upload date
    Uploaded using Trusted Publishing?
    What is trusted publishing?
    No
    Uploaded via twine/4.0.1 CPython/3.10.6

    Release history Release notifications | RSS feed

    This release

    0.0.3 This release

    2 release files

    0.0.2

    2 release files

    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