Boilertalk / Web3.swift

A pure swift Ethereum Web3 library
MIT License
636 stars 187 forks source link

ABIDecoder - Decoding failed #167

Open LiuGuoli opened 12 months ago

LiuGuoli commented 12 months ago

Hi,

I need to decrypt the actual parameters from parameters and dataString. However, the decryption is failing, and I check that the failure is due to the bytes field being empty in the parameters. Does the current SDK not support decoding when the bytes field is empty, or am I using it incorrectly?

let parameters: [SolidityType] = [.address, .uint16, .uint256, .address, .address, .bytes(length: nil)] let dataString = "000000000000000000000000174d056ea9944d49c6f67491541922f524869bc9 0000000000000000000000000000000000000000000000000000000000000065 00000000000000000000000000000000000000000000000014d1120d7b160000 000000000000000000000000174d056ea9944d49c6f67491541922f524869bc9 0000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000c0 0000000000000000000000000000000000000000000000000000000000000000"; do { let decodeParamters = try ABI.decodeParameters(types: parameters, from: dataString) } catch let error { print("Error: (error)") //Error: couldNotDecodeType(type: Web3ContractABI.SolidityType.type(Web3ContractABI.SolidityType.ValueType.bytes(length: nil)), string: "0000000000000000000000000000000000000000000000000000000000000000") }

Thanks

dev-johnny-gh commented 2 weeks ago

same issue here