1

I understand web3 can be basically used for every existing task, however, is there anything we can use for C? My C program is communicating with the RPC server using the curl library, by posting JSON data to the server via HTTP. However, the data of a transaction part, currently, I have to get the hex code from somewhere else(web3.js Remix etc.). Is it possible for me to construct the hex code of a function call in C directly without relying on calling a javacript program using system(node ...)? I understand SHA3-256 is used for hashing a function call using the abi information and parameter information, however, the sha3-256 generator that I have used do not produce the same result as web3. Calling system(node ...) is too slow. I want to use C because C is often faster... And my project requirement, it has to be C.

1
  • There's a pull request to keccak-tiny repo that adds support for ethereum flavor github.com/coruus/keccak-tiny/pull/2. Ethereum uses the same algorithm but with different parameters than sha3.
    – Ismael
    Commented Apr 18, 2019 at 22:17

1 Answer 1

2

Yes, you can do it without going through javascript. Calling a function in a smart contract is just inputing the correct value in the data field of your transaction.

Basically, an input is made of the 4 first bytes of the hash of the function's signature and following it, every value of the arguments padded to 32 bytes (if the arguments are of "simple" types).

You can read more here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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