Giter Club home page Giter Club logo

sea-counter's Introduction

Seahorse Counter

Solana program (smart contract) has a very unique programming model. A counter program is one of the simplest examples to demonstrate how data storage is handled. Meanwhile using Seahorse framework is the most elegant way to develop Solana programs.

Seahorse Setup

Follow this blog to install Seahorse, your installations sequence will be Rust > Solana > Anchor > Seahorse.

Note

Beware some old materials refer to the seahorse-lang package, which has been abandoned. If you have a Seahorse version 0.2.7, it's very likely you installed the wrong package. Install seahorse-dev instead.

The most stable software combination as of writing is as follows:

  • Rust 1.77.2
  • Solana 1.18.12
  • Anchor 0.29.0
  • Seahorse 0.2.0

How to Use Seahorse

Important

You can think Seahorse as a code generator, it parses the Python syntax and generate Anchor codes, abstracting away the most boilerplate codes as possible.

  1. Create a Solana wallet account with solana-keygen new if you haven't done so. Your private key is located at ~/.config/solana/id.json

  2. Initialize your project folder with seahorse init <program_name>

  3. Go to the project folder and build the Anchor sources with anchor build. It takes several minutes but only required to do once.

  4. You may start writing your Seahorse program in programs_py/<program_name>.py

  5. Run anchor keys list to find the correct program ID. Make sure the one found in Anchor.toml and that enclosed in the declare_id() statement are in sync.

  6. Compile your Seahorse program into Anchor with seahorse build. You can also get the IDL under target/idl/

  7. With the IDL, you can now start writing the Mocha test cases in tests/<program_name>.ts. Autocomplete is supported.

  8. Run anchor test to deploy the Anchor program to localnet and run the test script at the same time.

  9. Every time you modify the Seahorse program, changes are not synchronized to Anchor codes automatically. You may create a Node script in package.json to streamline the tasks.


#AwesomeSolana

sea-counter's People

Contributors

kenchan0824 avatar

Watchers

 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.