|
| 1 | +[![Build status][travis-image]][travis-url] |
| 2 | + |
| 3 | +[travis-image]: https://travis-ci.org/solana-labs/example-helloworld.svg?branch=master |
| 4 | +[travis-url]: https://travis-ci.org/solana-labs/example-helloworld |
| 5 | + |
| 6 | +# Hello world on Solana |
| 7 | + |
| 8 | +This project demonstrates how to use the [Solana Javascript API](https://github.com/solana-labs/solana-web3.js) |
| 9 | +to build, deploy, and interact with programs on the Solana blockchain. |
| 10 | + |
| 11 | +The project comprises of: |
| 12 | + |
| 13 | +* An on-chain hello world program |
| 14 | +* Client that can send a "hello" to an account and get back the number of times hello has been sent |
| 15 | + |
| 16 | +## Table of Contents |
| 17 | +- [Hello world on Solana](#hello-world-on-solana) |
| 18 | + - [Table of Contents](#table-of-contents) |
| 19 | + - [Getting Started](#getting-started) |
| 20 | + - [Start local Solana cluster](#start-local-solana-cluster) |
| 21 | + - [Build the on-chain program](#build-the-on-chain-program) |
| 22 | + - [Run client](#run-client) |
| 23 | + - [Customizing the Program](#customizing-the-program) |
| 24 | + - [Learn about Solana](#learn-about-solana) |
| 25 | + - [Learn about the on-chain program](#learn-about-the-on-chain-program) |
| 26 | + - [Learn about the client](#learn-about-the-client) |
| 27 | + - [Public Solana cluster](#public-solana-cluster) |
| 28 | + |
| 29 | +## Getting Started |
| 30 | + |
| 31 | +The following dependencies are required to build and run this example, |
| 32 | +depending on your OS they may already be installed: |
| 33 | + |
| 34 | +```bash |
| 35 | +$ npm --version |
| 36 | +$ docker -v |
| 37 | +$ wget --version |
| 38 | +$ rustc --version |
| 39 | +``` |
| 40 | + |
| 41 | +Next fetch the `npm` dependencies, including `@solana/web3.js`, by running: |
| 42 | +```bash |
| 43 | +$ npm install |
| 44 | +``` |
| 45 | + |
| 46 | +### Start local Solana cluster |
| 47 | + |
| 48 | +This example connects to a local Solana cluster by default. |
| 49 | + |
| 50 | +Enable on-chain program logs: |
| 51 | +```bash |
| 52 | +$ export RUST_LOG=solana_runtime::native_loader=trace,solana_runtime::system_instruction_processor=trace,solana_runtime::bank=debug,solana_bpf_loader=debug,solana_rbpf=debug |
| 53 | +``` |
| 54 | + |
| 55 | +Start a local Solana cluster: |
| 56 | +```bash |
| 57 | +$ npm run localnet:update |
| 58 | +$ npm run localnet:up |
| 59 | +``` |
| 60 | + |
| 61 | +Get cluster log: |
| 62 | +```bash |
| 63 | +$ npm run localnet:logs |
| 64 | +``` |
| 65 | + |
| 66 | +To stop the local Solana cluster run: |
| 67 | +```bash |
| 68 | +$ npm run localnet:down |
| 69 | +``` |
| 70 | + |
| 71 | +### Build the on-chain program |
| 72 | + |
| 73 | +```bash |
| 74 | +$ npm run build:program |
| 75 | +``` |
| 76 | + |
| 77 | +### Run client |
| 78 | + |
| 79 | +```bash |
| 80 | +$ npm run start |
| 81 | +``` |
| 82 | + |
| 83 | +### Customizing the Program |
| 84 | + |
| 85 | +To customize the example, make changes to the files under `/src`. If you change source under `/src/program` you will need to [rebuild the on-chain program](#Build-the-on-chain-program) |
| 86 | + |
| 87 | +Now when you rerun `npm run start`, you should see the results of your changes. |
| 88 | + |
| 89 | +## Learn about Solana |
| 90 | + |
| 91 | +More information about how Solana works is available in the [Book](https://docs.solana.com/book/) |
| 92 | + |
| 93 | +## Learn about the on-chain program |
| 94 | + |
| 95 | +TODO |
| 96 | + |
| 97 | +## Learn about the client |
| 98 | + |
| 99 | +TODO |
| 100 | + |
| 101 | +## Public Solana cluster |
| 102 | + |
| 103 | +Solana maintains a public development cluster called devnet. To connect to the devnet instead of the local cluster set the environment variable `LIVE` to 1, unset to point back to the local cluster |
| 104 | +```bash |
| 105 | +$ export LIVE=1 |
| 106 | +``` |
0 commit comments