KintabaHQ / EtherKit

Apache License 2.0
42 stars 6 forks source link

Send Data type error #34

Closed fortmarek closed 6 years ago

fortmarek commented 6 years ago

I have a problem sending Data. Other types work, but Data throws this error: "gas required exceeds allowance or always failing transaction"

let helloTwoFunctionCall = Function(name: "helloData", parameters: [Data("extra".utf8)])
let helloTwoData = GeneralData(data: helloTwoFunctionCall.encodeToCall())
self.etherQuery.send(using: using, to: self.at, value: amount, data: helloTwoData, completion: { result in
pr0zac commented 6 years ago

Hey @fortmarek can you give me more info on the contract function you're trying to call? IE, what does it expect the Data parameter type to be? Its likely because of how we decide how to encode Data into bytes based on length. I might have fixed the problem with my most recent commit to master, but if not you may have to specify the expected byte length for the parameter much like: let helloTwoFunctionCall = Function(name: "helloData", parameters: [ABIType.bytes(count: .constrained(8), value: Data("extra".utf8))]) Or if its expecting an unconstrained "bytes" type: let helloTwoFunctionCall = Function(name: "helloData", parameters: [ABIType.bytes(count: .unlimited, value: Data("extra".utf8))]) Lemme know if either of these work.

fortmarek commented 6 years ago

Yeah, I have to specify the byte length, but it works, so I think it's OK to close this now.