mschneider / solcpp

A fast Solana and Mango Markets C++ SDK
Other
39 stars 12 forks source link

Implement anchor IDL support for C++ #80

Open godmodegalactus opened 1 year ago

godmodegalactus commented 1 year ago

We want to implement anchor IDL support for solcpp. At start we do not expect a runtime support for IDL but a generator is fine. The generator will create classes, methods which can be compiled and used to interact with onchain program. This generator can be in any language but preferably python, typescript etc.

For more info check : https://www.anchor-lang.com/docs/cli#idl

What is anchor IDL : When you create a smart contract for solana with anchor, with anchor cli you can also create an IDL for the same program. The IDL consists of information about the instructions handled by the program in binary format. This IDL is then uploaded in the cluster so that anyone can query the cluster to find out which instructions are available for a smart contract.

Check https://kevinheavey.github.io/anchorpy/clientgen/ for python implementation to decrypt IDL. The you should be able to compile this c++ class and then link create library.

You should then test your implementation to interact with basic program like: https://github.com/coral-xyz/anchor/tree/master/tests/tictactoe