henkaku-center / badge

4 stars 3 forks source link

decode script #34

Open SamuraiT opened 2 years ago

SamuraiT commented 2 years ago
> data = '0x8be85aa800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000007368747470733a2f2f6261666b72656966656d7637696f6834676968346b676c667363746a776f796b33363766756a657070616779766c677673656672616b79327875692e697066732e647765622e6c696e6b2f3f66696c656e616d653d696e7669746174696f6e2d7469636b65742e6a736f6e00000000000000000000000000'
> ethers.utils.defaultAbiCoder.decode(['bool','bool', 'uint256', 'uint256', 'string', 'uint256'], ethers.utils.hexDataSlice(data, 4))
[
  true,
  true,
  BigNumber { _hex: '0x01', _isBigNumber: true },
  BigNumber { _hex: '0x3635c9adc5dea00000', _isBigNumber: true },
  [Getter],
  BigNumber { _hex: '0xc0', _isBigNumber: true }
]
SamuraiT commented 2 years ago

this one is much better soulution

data = '0x8be85aa800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000003635c9adc5dea00000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000007368747470733a2f2f6261666b72656966656d7637696f6834676968346b676c667363746a776f796b33363766756a657070616779766c677673656672616b79327875692e697066732e647765622e6c696e6b2f3f66696c656e616d653d696e7669746174696f6e2d7469636b65742e6a736f6e00000000000000000000000000'
let abi = ["function createBadge(tuple(bool mintable,bool transferable,uint256 amount,uint256 maxSupply,string tokenURI,uint256 maxMintPerWallet) Badge)"]
let iface = new ethers.utils.Interface(abi);
let r = iface.parseTransaction({data})
console.log(r.args[0])