Giter Club home page Giter Club logo

solnet.anchor's Introduction

Build Release Code License Discord

Solnet.Anchor

Solnet.Anchor is a set of tools to generate C# code to interact with Solana Anchor programs.

Features

This repo contains 3 main projects:

  • Solnet.Anchor: IDL parsing and code generation
  • Solnet.Anchor.Tool: dotnet tool executable that interfaces with the project above.
  • Solnet.Anchor.SourceGenerator: Roslyn source generator that depends on the tool above to automatically generate code from IDL in your IDE.

Currently covers all of IDL features with the exception of events and seeds.

Requirements

Solnet.Anchor and Solnet.Anchor.Tool are compiled and run in net6. Could be easily backported to net5. Solnet.Anchor.SourceGenerator is compiled in netstandard2.1 to be able to be used as a Roslyn Source Generator. However, machine needs net6 as it just calls Solnet.Anchor.Tool that requires net6.

Generated code can be run using net5 or net6, and the respective Solnet version >=5.0.3 or >=6.0.3 libraries.

Instructions

To compile this project:

dotnet build

To use the generator tool:

  • dotnet tool install Solnet.Anchor.Tool (if you use -g option, you won't need to do this for every project')
  • dotnet anchorgen -i idl/file.json -o src/ProgramCode.cs
    • You can generate from a live program that uploaded its idl using flag -a, or add the default program address if used alongside -i
    • You stdout output is supported using -s flag

To use the source generator roslyn plugin:

  • In your .csproj add <PackageReference Include="Solnet.Anchor.SourceGenerator" OutputItemType="Analyzer" ReferenceOutputAssembly="false"/>
  • For each project you want to generate sources from an address, add inside PropertyGroup: <AnchorGenerator>address1,address2</AnchorGenerator>
  • For each project you want to generate sources from IDL, add <AdditionalFiles Include="IdlFile.json" Address="GDDMwNyyx8uB6zrqwBFHjLLG3TBYk2F8Az4yrQC5RzMp" AnchorGenerate="true" />

Support

Consider supporting us:

  • Sol Address: oaksGKfwkFZwCniyCF35ZVxHDPexQ3keXNTiLa7RCSp
  • Mango Ref Link

Contribution

We encourage everyone to contribute, submit issues, PRs, discuss. Every kind of help is welcome.

Maintainers

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE file for details

solnet.anchor's People

Contributors

tiago18c avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.