my attempt is to call a view function to reatrieve some data from a contract on the Blockchain using a C program. I do have the interface of the contract.

I think i need to performe two things in order to accomplish this task:

  • First of all the program needs to connect to a node running the EVM. Usually easy using Metamask and web3.js. I don't thinks it's so easy even in this case. Is it possibile to connect to a node without using Metamask? What would you do to do this? What do you think will be the biggest problem of this task?
  • Second i need to create a raw transaction to send to the node and by raw i mean real raw. Anyway once i've a connection this shouldn't be impossible. Since i just need to call one function i was thinking of making one call using remix or truffle then inspect the data sent and try to replicate it the connection opened from the C program. Do you think it's possible to do such a thing? What part does it seems impossibile to you?

Of course i also ask you if you know of any project or any people who have done something like this, even in other languages, i'll really appreciate if you post it.

  • I am developing a wallet , entirely in C++ , it sends transactions to contracts and EOAs , so , it is possible to do what you want in C. But I wonder why would you need C if you are more like a Java programmer.
    – Nulik
    Aug 21 '18 at 19:28
  • @Nulik thanks for your reply. The device who should then run the program isn't mine, they told it can't run the JVM and it must be done in C.
    – D.Rek
    Aug 22 '18 at 6:42
  • 1
    well, the shared library with all the functions to send transactions is 4.1M , add the code to actually use the library + send raw transaction to the network via HTTP and that's what you will have as executable size at the end. And my wallet is 14MB including debugging symbols, unstripped, unoptimized.
    – Nulik
    Aug 22 '18 at 13:12

I think you can refer to native dapp. We can binding golang code to smart contract then call it



Is there a c++ library to encode abi

you need to change stream operations to char * stuff.
info on how to encode args https://docs.soliditylang.org/en/v0.5.3/abi-spec.html
so you need a node provider and some service to sign tx without having key in code. i use ethsigner

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.