No project description provided
Project description
eth-uniswap
eth-uniswap is a python wrapper built ontop the web3py library to interact with Uniswap solidity contracts on a public or private ethereum blockchain.
The library defines a python function for each function defined by the solidity contracts in python, adding type hints for the arguments and return values. This makes it easier to call the contracts' function by enabling IDE features such as auto-completion.
Installation
You can install the eth-uniswap package using pip:
python -m pip install eth-uniswap
Getting started
Here is how to deploy and use the Uniswap-V2 Factory solidity contract using this library:
# First, you need a connection to an ethereum node.
# Here, we are using a local node created with ganache-cli for instance.
from web3 import Web3, HTTPProvider
url = "http://127.0.0.1:8545"
w3 = Web3(HTTPProvider(url))
# We can deploy the factory as follows:
from eth_uniswap.v2.core import UniswapV2Factory
receipt = UniswapV2Factory.deploy(w3, my_address).waitForReceipt()
factory = receipt.contract
# Alternatively, we can connect to a deployed instance:
factory_address = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'
factory = UniswapV2Factory(w3, address=factory_address)
# All the functions defined by the solidity contract are available.
# For instance, here is how to make an eth-call on the allPairsLength function:
nb_pairs = factory.functions.allPairsLength().call()
print("This many pairs have been deployed', nb_pairs)
# Here is how to send a transaction to the createPair function
token1 = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
token2 = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
receipt = factory.functions.createPair(token1, token2).waitForReceipt()
Documentation
For each solidity contract defined by Uniswap, this package contains a python class with the same name and its methods also have the same name as the solidity one. This makes it easy to find the class and method you are looking for. Refer to Uniswap documentation to learn how to interact with the contracts.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eth-uniswap-0.0.2.tar.gz.
File metadata
- Download URL: eth-uniswap-0.0.2.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e0a148b520b31f03834b69615280419817f0a63cfdab61b83af2dd7a3a8a162
|
|
| MD5 |
81852999424c725f7ec5b9f61677a32b
|
|
| BLAKE2b-256 |
b0f453cadbb7380d23eeb6eb49ca324d8988fb12b3b7e3603d3fb383edf801f5
|
File details
Details for the file eth_uniswap-0.0.2-py3-none-any.whl.
File metadata
- Download URL: eth_uniswap-0.0.2-py3-none-any.whl
- Upload date:
- Size: 15.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6e1ef8068960c5fff62322cd3cc1dbdb0927a0512e90ebe719db66a5b5852d1
|
|
| MD5 |
b7e3a438e0b381d661e387fb58f8fed0
|
|
| BLAKE2b-256 |
34f6f81aaaa1b5f63c791f74c8377594cc42be11471e9ddbf4222dcfcd1fb341
|