KintabaHQ / EtherKit

Apache License 2.0
42 stars 6 forks source link

question: calling contract functions #19

Closed pteasima closed 6 years ago

pteasima commented 6 years ago

Hey guys, if its not too much trouble, could you give a simple example of what data: GeneralData argument I could pass to the send(using:from:to:value:data:completion:) method in order to call a particular function of a smart contract?

Choose your own example contract or use the following (only including ABI of the single function):

{ "constant": true, "inputs": [ { "name": "message", "type": "string" } ], "name": "say", "outputs": [ { "name": "result", "type": "string", "value": "" } ], "payable": false, "stateMutability": "pure", "type": "function" }

Thanks for your response, Petr from Ackee

pr0zac commented 6 years ago

Hey Petr!

Sorry about the slow response time, been a bit swamped!

Currently yes you'll need to serialize the data according to the spec as we don't yet have ABI support in EtherKit. Its on my list of features to add shortly though, I've actually written part of it already but haven't had time to test everything and get it in place. I'll hopefully get back to it soon though, especially now that I know its something people are interested in.

The TypedData stuff is a different encoding format used for signing messages outside transactions (cause everyone loves a third way to encode data) and is unrelated to your question here.

Hope this helps! -Zac

pteasima commented 6 years ago

Thanks for the response Zac. Our timeline absolutelly allows us to wait for this feature. Ill keep checking the repo, but if you can remember please close this issue when its done. Thanks again, Petr

pr0zac commented 6 years ago

Hey @pteasima I just landed the first version of ABI encoding support if you wanna give it a try! Lemme know if you have any questions or find any bugs with it.

https://github.com/Vaultio/EtherKit/blob/master/EtherKit/ABI.swift