Decode transaction sent to Uniswap universal router
Project description
Uniswap Universal Router Decoder
Description
The object of this library is to decode the transaction input sent to the Uniswap universal router
(address 0xEf1c6E67703c7BD7107eed8303Fbe6EC2554BF6B
on Ethereum Mainnet).
⚠ Not all commands are decoded yet. Below a list of the commands that have already been implemented.
| Command Id | Function Name | Is Implemented |
|---|---|---|
| 0x00 | V3_SWAP_EXACT_IN | ✅ |
| 0x01 | V3_SWAP_EXACT_OUT | ✅ |
| 0x08 | V2_SWAP_EXACT_IN | ✅ |
| 0x09 | V2_SWAP_EXACT_OUT | ✅ |
| 0x0a | PERMIT2_PERMIT | ✅ |
| 0x0b | WRAP_ETH | ✅ |
| 0x0c | UNWRAP_WETH | ✅ |
Installation
# update pip to latest version if needed
pip install -U pip
# install the decoder from pypi.org
pip install uniswap-universal-router-decoder
Usage
The library exposes a class, RouterDecoder with 2 public methods decode_function_input and decode_transaction.
To decode a transaction input:
from uniswap_universal_router_decoder.router_decoder import RouterDecoder
trx_input = "0x3593564c000000000000000000 ... 90095b5c4e9f5845bba" # the trx input to decode
decoder = RouterDecoder()
decoded_trx_input = decoder.decode_transaction(trx_input)
It's also possible to decode the whole transaction, given its hash and providing the decoder has been built with either a valid Web3 instance or the link to a rpc endpoint:
# Using a web3 instance
from web3 import Web3
from uniswap_universal_router_decoder.router_decoder import RouterDecoder
w3 = Web3(...) # your web3 instance
decoder = RouterDecoder(w3=w3)
# Using a rpc endpoint
from web3 import Web3
from uniswap_universal_router_decoder.router_decoder import RouterDecoder
rpc_link = "https://..." # your rpc enpoint
decoder = RouterDecoder(rpc_endpoint=rpc_link)
And then the decoder will get the transaction from the blockchain and decode it, along with its input data:
# Using a rpc endpoint
trx_hash = "0x52e63b7 ... 11b979dd9"
decoded_transaction = decoder.decode_transaction(trx_hash)
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 uniswap-universal-router-decoder-0.2.0.tar.gz.
File metadata
- Download URL: uniswap-universal-router-decoder-0.2.0.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3a9fd0be0f57e7bfe07b7ac66046f0064b2684804140e5e3d3b8e2fe45a725e
|
|
| MD5 |
4e786cef34460d71acfb3e035aec4223
|
|
| BLAKE2b-256 |
ed41df6703b250d472e07e70f84c79a19912164f0627a34fca77403aa36cf5c0
|
File details
Details for the file uniswap_universal_router_decoder-0.2.0-py3-none-any.whl.
File metadata
- Download URL: uniswap_universal_router_decoder-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6868cf3ef496e2e52f635e701db033ec13987e236e8f9645ad139411cacd8991
|
|
| MD5 |
d53719a3e24982eb606707945dbf28d6
|
|
| BLAKE2b-256 |
f2c9649d7e256e54c84b861221b1d2df0ca10164536fb83cbfb179188a98c916
|