Code Monkey home page Code Monkey logo

hello-world-solana's Introduction

Hello, World! Solana Smart Contract

This project demonstrates a basic smart contract written in Rust with Anchor. It comes with a smart contract and a test for the contract.


Setup the Project

Before you can run the project test cases you will need to install dependencies and setup your keypair.

Install Rust

First make sure you have the Rust programming language installed, you can follow the installation guide here:

Verify that Rust and Cargo were installed correctly by running the following commands.

rustup --version
rustc --version
cargo --version

Install Solana and Anchor

Follow the installation steps here to install the Solana CLI. This is a necessary step to test contracts locally.

Verify that solana was installed correctly:

solana --version

Run some config commands:

solana config set --url localhost
solana config get

Install Anchor, a popular development framework for Solana. To learn more about Anchor, check out The Anchor Book.

cargo install --git https://github.com/project-serum/anchor anchor-cli --locked

Verify the installation

anchor --version

Install the remaining npm dependencies

npm install

Setup a keypair to communicate with the contract

Generate a new keypair

solana-keygen new -o target/deploy/hello-world-solana-keypair.json

Verify that the wallet property in Anchor.toml is pointing to the keypair we just created

wallet = "target/deploy/hello-world-solana-keypair.json"

Some Common Commands

List Anchor Commands

anchor

Build Contracts

anchor build

Run test cases

anchor test

Deploy the smart contract

anchor deploy <project_path>/target/deploy/hello_world_solana.so

When deploying, you can override the project address by passing --program-id


Next Steps

Add additional functionality to the contract

  • Let users like/dislike messages
  • Emit an event when a message is liked/disliked
  • Let users reply to messages

Setup a frontend for users to interact with your contract

  • Explore options like @solana/web3.js to make frontend web3 development a breeze

hello-world-solana's People

Contributors

joshmayr 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.