1

Assuming I have a device that receives sensor data in C, and I want to make calls to an Ethereum smart contract directly through it, is there a way to use C/C++ for that communication? Something similar to web3 for js or python is what I am ideally looking for.

I am interested in knowing whether or not this is possible at all, so feel free to ignore my rough example. If it is not, then suggestions as to how this could be approached through a device like the one mentioned are welcome.

3 Answers 3

1

EVM is essentially a stack machine, you can use Ethereum WebAssembly - EWASM, currently, it is in the development phase.

From this Article:

Ewasm will support more languages and will benefit from a more extensive set of tools than the EVM.⁹ Some prominent examples of additional languages supported by Ewasm include, C, C++ and Rust.⁷ Ewasm will also enjoy native support from many prominent JavaScript engines

2
  • Thank you, that seems to be the closest thing I've seen to what I am looking for. Do you know if it is operational on any level? And beyond writing the contract in said languages, does it also make it possible to interact with them in C? Apr 13, 2021 at 14:43
  • 1
    @riverwastaken sure, you can check this out github.com/ewasm/hera. It is aleth and geth compliant. this might help too: github.com/ewasm/wabt
    – hack3r-0m
    Apr 13, 2021 at 15:42
1

Aleth is/was the official C++ Ethereum implementation, though it hasn't been updated in 18 months, and generally the Go implementation (Geth) is pushed as the de facto official implementation now.

The associated C++ Web3 library - libweb3jsonrpc - can be found in this Aleth repo.

0

As others have mentioned, the web3 libraries are built on the Ethereum JSON API through which you can send requests using any simple networking library, of which I'm sure there are plenty of in whichever language you seek to make it work with. (Taken from this article which also has more information on implementation)

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.