Solnet icon indicating copy to clipboard operation
Solnet copied to clipboard

Support for smart contracts

Open Liebeck opened this issue 2 years ago • 4 comments

As far as I understand, smart contracts for Solana are written in Rust, C or C++ and then compiled into Solana BPF Bytecode.

Is there anything planned for Solnet in terms of smart contract support? So far I've only used Solnet as JSON RPC API wrapper to interact with the nodes. It would be great to be able to use C# for smart contracts, similar to NEO.

Liebeck avatar Oct 27 '21 20:10 Liebeck

I've entertained this idea since the first days of Solnet. We have two possible ways to go about it:

  • Use some C# front-end for LLVM and compile as BPF.
  • Transpile into Rust and call the current Solana toolchain.

Using the first one, we would lose a ton of facilities built into anchor, unless we would re-implement those same features but sounds counterintuitive. The second option means we'd possibly lose a lot of expressiveness from both languages.

There could be some other option I'm missing or misinterpreting, feel free to suggest some other way.

tiago18c avatar Oct 28 '21 19:10 tiago18c

@tiago18c I think a loss of language features is inevitable, e.g., reflection calls etc.

For NEO, I found their way of using C# for smart contracts and I like it: https://docs.neo.org/docs/en-us/develop/write/basics.html However, that get's compiled into their own intermediate format and not BPF. Maybe their implementation can give you some ideas.

Liebeck avatar Oct 29 '21 07:10 Liebeck

Well, as of now I'm too busted with work, so I'll have to leave this for the community. I will gladly oversee and review if anyone is up to the task.

Going forward, one thing that would be fundamental would be Anchor-like functionality and IDL generation. (I'm still working on finishing Solnet.Anchor).

I also suggest anyone interested to get in touch with us, as this would easily qualify for a grant given the scope of the work.

tiago18c avatar Oct 29 '21 11:10 tiago18c

Transpile into Rust and call the current Solana toolchain. if we want to translate the whole thing to Rust, it sounds counter-intuitive too. Probably we could make some limited template for popular themes that people use in smart contract (such as splitting some amount among variable/hard-coded public keys), and then let people build up these templates from C#.

We also have some limited NativeAOT with LLVM backend for C# (see here and here) but sounds very hard to get anything working considering NativeAOT is still in preview itself!

I am actually thinking about making smart contracts available from C# code base but things are hard to be handled by a single person.I can start working on some popular themes for smart contracts if you agree with this approach

Neo-vortex avatar Feb 27 '22 17:02 Neo-vortex