-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecodeTx.ts
15 lines (12 loc) · 1.16 KB
/
decodeTx.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import * as ethers from 'ethers';
const txHex = '0x02f90135830138818085108fb314cd8512e3bef8cd83030d4094a07e45a987f19e25176c877d98388878622623fa80b8c4f242432a000000000000000000000000ea4d6c34410bf6b604e349895bc0d9e36265f55700000000000000000000000025281016cb3dd8db8302cc6a61cf4afdffb8480f000000000000000000000000000000000000000000000000000000000000007b000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000000c080a0ab31641301b64df2e0ad1cc1fd40b990992974bd6e5b60ee131f25bd35c4e068a02415fa0489306724b04793fe226a5f2e014392f1db1fa8bb906042c2011d1f4a';
console.log(ethers.utils.parseTransaction(txHex));
const ABI = [
"function methodName(address,uint256)"
];
const iface = new ethers.utils.Interface(ABI);
const encodedData = iface.encodeFunctionData("methodName", ['0x50D4C450F091e549A3059d2e47043CC184f09886', 1]);
console.log('encode with signature: ', encodedData);
let provider = ethers.getDefaultProvider('goerli');
const data = provider.getStorageAt('0x8F325A8777bE8b99d19430371bfe7848c196969B', 5);
data.then(d => console.log('storage at: ', d));