Decode transaction inputs based on the contract ABI
Project description
# ethereum-input-decoder
Decode transaction inputs and constructor arguments based on the ethereum contract ABI
* python3
* suggested as a PR to [eth-abi #69](https://github.com/ethereum/eth-abi/pull/69)
* the heavy lifting is done by `eth-abi`
* utilized in [pyetherchain](https://github.com/tintinweb/pyetherchain) to decode and dump smart contract code with inputs
Decode transaction inputs and constructor arguments to contract at [0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e](https://etherscan.io/address/0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e#code) to a more human friendly notation.
## CLI
Usage:
python -m ethereum_input_decoder -a ./test/contract_abi_ab7c74abc0c4d48d1bdad5dcb26153fc8780f83e.json -c 000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000002903cadbe271e057edef157340b52a5898d7424f000000000000000000000000ba7ca1bcf210c1b37cf5818816c4a819c3040ea700000000000000000000000014cd6536d449e3f6878f2d6859e1ff92ae0990e60000000000000000000000000c24441e42277445e38e02dfc3494577c05ba46b -t 0x797af62798d790d3133e0049215669e09b55a0b59d586c95f94c2d56b2812040133d7707 -t 0x797af62798d790d3133e0049215669e09b55a0b59d586c95f94c2d56b2812040133d7707
Output:
==[Constructor]==
Raw: '000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000002903cadbe271e057edef157340b52a5898d7424f000000000000000000000000ba7ca1bcf210c1b37cf5818816c4a819c3040ea700000000000000000000000014cd6536d449e3f6878f2d6859e1ff92ae0990e60000000000000000000000000c24441e42277445e38e02dfc3494577c05ba46b'
Description: constructor None ((address[]) _owners = ('0x2903cadbe271e057edef157340b52a5898d7424f', '0xba7ca1bcf210c1b37cf5818816c4a819c3040ea7', '0x14cd6536d449e3f6878f2d6859e1ff92ae0990e6', '0x0c24441e42277445e38e02dfc3494577c05ba46b'), (uint256) _required = 2, (uint256) _daylimit = 1000000000000000000) returns ()
==[Input]==
Raw: '0x797af62798d790d3133e0049215669e09b55a0b59d586c95f94c2d56b2812040133d7707'
Description: function confirm ((bytes32) _h = b'\x98\xd7\x90\xd3\x13>\x00I!Vi\xe0\x9bU\xa0\xb5\x9dXl\x95\xf9L-V\xb2\x81 @\x13=w\x07') returns ((bool) )
## API
```python
from ethereum_input_decoder import ContractAbi
ca = ContractAbi(json.loads(json_abi_str))
print(ca.describe_input(b'797aaf...3d7707'))
# function confirm ((bytes32) _h = b'\x98\xd7\x90\xd3\x13>\x00I!Vi\xe0\x9bU\xa0\xb5\x9dXl\x95\xf9L-V\xb2\x81 @\x13=w\x07') returns ((bool) )
print(ca.describe_constructor(b'000000...5ba46b")))
# constructor None ((address[]) _owners = ('0x2903cadbe271e057edef157340b52a5898d7424f', '0xba7ca1bcf210c1b37cf5818816c4a819c3040ea7', '0x14cd6536d449e3f6878f2d6859e1ff92ae0990e6', '0x0c24441e42277445e38e02dfc3494577c05ba46b'), (uint256) _required = 2, (uint256) _daylimit = 1000000000000000000) returns ()
```
Decode transaction inputs and constructor arguments based on the ethereum contract ABI
* python3
* suggested as a PR to [eth-abi #69](https://github.com/ethereum/eth-abi/pull/69)
* the heavy lifting is done by `eth-abi`
* utilized in [pyetherchain](https://github.com/tintinweb/pyetherchain) to decode and dump smart contract code with inputs
Decode transaction inputs and constructor arguments to contract at [0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e](https://etherscan.io/address/0xab7c74abc0c4d48d1bdad5dcb26153fc8780f83e#code) to a more human friendly notation.
## CLI
Usage:
python -m ethereum_input_decoder -a ./test/contract_abi_ab7c74abc0c4d48d1bdad5dcb26153fc8780f83e.json -c 000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000002903cadbe271e057edef157340b52a5898d7424f000000000000000000000000ba7ca1bcf210c1b37cf5818816c4a819c3040ea700000000000000000000000014cd6536d449e3f6878f2d6859e1ff92ae0990e60000000000000000000000000c24441e42277445e38e02dfc3494577c05ba46b -t 0x797af62798d790d3133e0049215669e09b55a0b59d586c95f94c2d56b2812040133d7707 -t 0x797af62798d790d3133e0049215669e09b55a0b59d586c95f94c2d56b2812040133d7707
Output:
==[Constructor]==
Raw: '000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000de0b6b3a764000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000002903cadbe271e057edef157340b52a5898d7424f000000000000000000000000ba7ca1bcf210c1b37cf5818816c4a819c3040ea700000000000000000000000014cd6536d449e3f6878f2d6859e1ff92ae0990e60000000000000000000000000c24441e42277445e38e02dfc3494577c05ba46b'
Description: constructor None ((address[]) _owners = ('0x2903cadbe271e057edef157340b52a5898d7424f', '0xba7ca1bcf210c1b37cf5818816c4a819c3040ea7', '0x14cd6536d449e3f6878f2d6859e1ff92ae0990e6', '0x0c24441e42277445e38e02dfc3494577c05ba46b'), (uint256) _required = 2, (uint256) _daylimit = 1000000000000000000) returns ()
==[Input]==
Raw: '0x797af62798d790d3133e0049215669e09b55a0b59d586c95f94c2d56b2812040133d7707'
Description: function confirm ((bytes32) _h = b'\x98\xd7\x90\xd3\x13>\x00I!Vi\xe0\x9bU\xa0\xb5\x9dXl\x95\xf9L-V\xb2\x81 @\x13=w\x07') returns ((bool) )
## API
```python
from ethereum_input_decoder import ContractAbi
ca = ContractAbi(json.loads(json_abi_str))
print(ca.describe_input(b'797aaf...3d7707'))
# function confirm ((bytes32) _h = b'\x98\xd7\x90\xd3\x13>\x00I!Vi\xe0\x9bU\xa0\xb5\x9dXl\x95\xf9L-V\xb2\x81 @\x13=w\x07') returns ((bool) )
print(ca.describe_constructor(b'000000...5ba46b")))
# constructor None ((address[]) _owners = ('0x2903cadbe271e057edef157340b52a5898d7424f', '0xba7ca1bcf210c1b37cf5818816c4a819c3040ea7', '0x14cd6536d449e3f6878f2d6859e1ff92ae0990e6', '0x0c24441e42277445e38e02dfc3494577c05ba46b'), (uint256) _required = 2, (uint256) _daylimit = 1000000000000000000) returns ()
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for ethereum_input_decoder-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2520d1fe778a15c84b64662c9674d697808b2ee28eafbeee90259f4ea01766b4 |
|
MD5 | 792b927670f083d529cc9eecc6fc12d8 |
|
BLAKE2b-256 | cac98cb9821221e1cef74d678991a8371e2cefebac54e9618d0a8abf7d22a289 |