No description
Find a file
2018-08-22 10:14:25 -05:00
test Adding ability to decode sigs. 2018-08-22 10:14:25 -05:00
.gitignore Getting rid of all the build stuff and prepping for the augment pieces I need. 2018-08-15 10:54:13 -05:00
index.js Adding ability to decode sigs. 2018-08-22 10:14:25 -05:00
LICENSE Initial commit 2017-02-15 13:23:13 +01:00
package-lock.json Getting rid of all the build stuff and prepping for the augment pieces I need. 2018-08-15 10:54:13 -05:00
package.json Getting rid of all the build stuff and prepping for the augment pieces I need. 2018-08-15 10:54:13 -05:00
README.md Getting rid of all the build stuff and prepping for the augment pieces I need. 2018-08-15 10:54:13 -05:00

eth-abi-utils

This repo is heavily inspired by consensys/abi-decoder. I essentially rewrote most of the fundamentals, but the algorithm is similar enough that I don't feel comfortable re-licensing it. So I will be keeping PR's open to abi-decoder to fulfill the GPL3 license.

Install

npm install eth-abi-utils
bower install eth-abi-utils

Instantiate

const abiDecoder = require('eth-abi-utils');

You can also create new instances of the decoder if you need to:

const anotherAbiDecoder = abiDecoder.instance();

Add ABI's

Need to pass the ABI's manually to the library in order to be able to decode params later

const testABI = [{"inputs": [{"type": "address", "name": ""}], "constant": true, "name": "isInstantiation", "payable": false, "outputs": [{"type": "bool", "name": ""}], "type": "function"}, {"inputs": [{"type": "address[]", "name": "_owners"}, {"type": "uint256", "name": "_required"}, {"type": "uint256", "name": "_dailyLimit"}], "constant": false, "name": "create", "payable": false, "outputs": [{"type": "address", "name": "wallet"}], "type": "function"}, {"inputs": [{"type": "address", "name": ""}, {"type": "uint256", "name": ""}], "constant": true, "name": "instantiations", "payable": false, "outputs": [{"type": "address", "name": ""}], "type": "function"}, {"inputs": [{"type": "address", "name": "creator"}], "constant": true, "name": "getInstantiationCount", "payable": false, "outputs": [{"type": "uint256", "name": ""}], "type": "function"}, {"inputs": [{"indexed": false, "type": "address", "name": "sender"}, {"indexed": false, "type": "address", "name": "instantiation"}], "type": "event", "name": "ContractInstantiation", "anonymous": false}];
abiDecoder.addABI(testABI);

Decode Tx data

const testData = "0x53d9d9100000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000a6d9c5f7d4de3cef51ad3b7235d79ccc95114de5000000000000000000000000a6d9c5f7d4de3cef51ad3b7235d79ccc95114daa";
const decodedData = abiDecoder.decodeMethod(testData);

Decode Logs from Tx Receipt

web3.eth.getTransactionReceipt("0x9199e262aaab0a6ec99558b3e9f42397c07a2bb9c6befb637643aebfb03cc32a", function(e, receipt) {
  const decodedLogs = abiDecoder.decodeLogs(receipt.logs);
});