Metadata-Version: 2.1
Name: eth_transfer
Version: 0.0.3
Summary: Easily send transactions on the Ethereum blockchain and fine tune gas parameters
Project-URL: Homepage, https://github.com/MidpriceDog/eth_transfer
Project-URL: Bug Tracker, https://github.com/MidpriceDog/eth_transfer/issues
Author: MidpriceDog
License: MIT License
        
        Copyright (c) 2022 Midprice Dog
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: blockchain,eth,ether,ethereum,wallet
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.7.*
Requires-Dist: matplotlib>=3.5.3
Requires-Dist: numpy>=1.23.2
Requires-Dist: pandas>=1.4.4
Requires-Dist: python-dotenv>=0.20.0
Requires-Dist: requests>=2.28.1
Requires-Dist: web3>=5.31.1
Requires-Dist: websockets>=9.1
Description-Content-Type: text/markdown

# eth_transfer

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

# Motivation

The [Web3.py](https://web3py.readthedocs.io/en/v5/) 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 <b>not</b> neeeded.

## Installing web3

If you do not have the web3 package installed in your environment or virtual environment, follow the quickstart [here](https://web3py.readthedocs.io/en/v5/quickstart.html). 

If you do not have an Etherscan account, create one as well as an API key by following the Getting Started steps [here](https://docs.etherscan.io/getting-started/creating-an-account).

# Quickstart

You can install the <code>eth_transfer</code> package via pip

```
pip3 install eth_transfer
```

## Sending a Transaction

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

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

Instantiate an instance of the <code>Tx</code> class

```python
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

```python
transaction.send_transaction()
```

## Tracking Gas Prices

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

<li>From variable with string of your API key

```python
etherscan_key = YOUR_ETHERSCAN_KEY
gastracker = GasTracker.from_key(etherscan_key)
```

</li>

<li> From env with your API Key

```python
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)
```

</li>

### Confirmation Times vs. Fee Per Gas

```python
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.

```python
gastracker.get_safe_gas_price()
```














