bsc
有专门做解析的库。
参考资料
例子
解析 input
要去掉 开头的 10
个字符,因为那是方法的加密字符。
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| const {decodeConstructorArgs} = require('canoe-solidity'); let abiExample = { 'abi': [ { "inputs": [ {"internalType": "uint256", "name": "amountOutMin", "type": "uint256"}, { "internalType": "address[]", "name": "path", "type": "address[]" }, {"internalType": "address", "name": "to", "type": "address"}, { "internalType": "uint256", "name": "deadline", "type": "uint256" } ], 'type': 'constructor' } ] }; let bytecodeExample = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000002fce9f84aef6d6cf03eb44dadf37f5b3b94e8fe4000000000000000000000000000000000000000000000000000000006134e4870000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000023662f3f9f35daab7a8d10654b5a4c1f3e57fc7a'; console.log(decodeConstructorArgs(abiExample.abi, bytecodeExample));
|
2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| let abiExample = [ { "inputs": [ {"type": "uint256"}, { "type": "address[]" }, {"type": "address"}, { "type": "uint256" } ], 'type': 'constructor' } ]; let bytecodeExample = '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000002fce9f84aef6d6cf03eb44dadf37f5b3b94e8fe4000000000000000000000000000000000000000000000000000000006134e4870000000000000000000000000000000000000000000000000000000000000002000000000000000000000000bb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c00000000000000000000000023662f3f9f35daab7a8d10654b5a4c1f3e57fc7a'; console.log(decodeConstructorArgs(abiExample, bytecodeExample));
|