Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
update projects
Browse files Browse the repository at this point in the history
  • Loading branch information
brimigs committed Jan 6, 2025
1 parent fae227d commit ca036d5
Show file tree
Hide file tree
Showing 15 changed files with 447 additions and 400 deletions.
4 changes: 2 additions & 2 deletions content/guides/getstarted/local-rust-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ library.
### Install Node.js

To use node in WSL2 on Windows, please follow this
[guide to installing node in WSL2](https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl)
to install node.
[guide to installing node in WSL2](https://learn.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl) to
install node.

```shell
sudo apt-get install curl
Expand Down
68 changes: 2 additions & 66 deletions docs/toolkit/best-practices.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,9 @@
---
title: Solana Smart Contract Best Practices
sidebarSortOrder: 3
sidebarLabel: Best Practices
---

## Smart Contract File Structure

Typically Solana smart contract (aka [programs](/docs/core/programs.md))
workspaces will be have the following file structure:

```shell
.
├── app
├── migrations
├── node_modules
├── programs
├── target
└── tests
```

The main smart contract is the `lib.rs` file, which lives insides the `programs`
directory, as shown below:

```shell
.
├── app
├── migrations
├── node_modules
├── programs
├── src
├── lib.rs
├── target
└── tests
```

As the smart contract gets more cumbersome, you'll typically want to separate
the logic into multiple files, as shown below:

```shell
├── programs
├── src
├── state.rs
├── instructions
├── instruction_1.rs
├── instruction_2.rs
├── instruction_3.rs
├── lib.rs
├── constants.rs
├── error.rs
├── mod.rs
```

For native rust smart contract development, you need to explicitly write out the
entrypoint and processor for the program, so you'll need a few more files:

```shell
├── program.rs
│ ├── src.rs
│ │ ├──assertions.rs
│ │ ├──entrypoint.rs
│ │ ├──error.rs
│ │ ├──instruction.rs
│ │ ├──lib.rs
│ │ ├──processor.rs
│ │ ├──state.rs
│ │ ├──utils.rs
│ ├── Cargo.toml
│ ├── keypair.json
│ ├── README.md
```

## Optimize Compute Usage

To prevent abuse of computational resources, each transaction is allocated a
Expand Down
83 changes: 19 additions & 64 deletions docs/toolkit/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
---
title: Getting Started
sidebarSortOrder: 1
sidebarLabel: Getting Started
---

The Solana Program development toolkit is publish as the
[mucho npm package](https://www.npmjs.com/package/mucho). The `mucho` command
will be used to run all the solana program development tools - _mucho tools, one
cli_.

## Installation

To get started, install The Solana toolkit:

```shell
npx solana install
npx mucho install
```

This will install the latest versions of the following:
Expand All @@ -25,7 +32,7 @@ This will install the latest versions of the following:
- [Code Coverage Tool](https://github.com/LimeChain/zest?tab=readme-ov-file): A
code coverage CLI tool for Solana programs.

## Keypair generation
### Generate a keypair

For a fresh installation of the [Solana CLI](https://docs.anza.xyz/cli/), you're
required to generate a new keypair.
Expand All @@ -34,39 +41,30 @@ required to generate a new keypair.
solana-keygen new
```

The above command will both:

- print the pubkey generated
- store the your new keypair at the Solana CLI's default path
(`~/.config/solana/id.json`) unless you already have a keypair saved there
_This will store the your new keypair at the Solana CLI's default path
(`~/.config/solana/id.json`) and print the pubkey that was generated._

Get the pubkey of your machine's newly generated keypair:
### Query your keypair's public key

```shell
solana address
```

## Fund the CLI keypair
### Fund your keypair

```shell
solana airdrop 10
solana airdrop 10 --url localhost
```

## Network Configuration
### Set your network configuration

Check your current configuration:
Check your current config:

```shell
solana config get
```

You can configure your RPC to connect to either mainnet, testnet, devnet, or
your localhost.

When using this toolkit, most of the time you'll want to be connected to a local
node.

Update your Solana configuration to connect to localhost:
To use this toolkit, update your config to connect to localhost:

```shell
solana config set --url localhost
Expand All @@ -75,51 +73,8 @@ solana config set --url localhost
To test locally, you must also spin up a local node to run on your localhost:

```shell
solana-test-validator
```

To log the network run:

```shell
solana logs
mucho validator
```

For a more information, read this
For a more information, read the
[Solana Test Validator Guide](https://solana.com/developers/guides/getstarted/solana-test-validator).

### Account Management

View the pubkey of your configured CLI keypair:

```shell
solana address
```

View the current balance of your keypair:

```shell
solana balance
```

To add SOL to your CLI keypair, request an airdrop:

```shell
solana airdrop 10
```

To retrieve details about any account, such as its balance and owner:

```shell
solana account <ACCOUNT_ADDRESS>
```

You must first add SOL to an account for it to exist. This airdrop command
requests 2 SOL to the specified account address:

```shell
solana airdrop 2 <ACCOUNT_ADDRESS>
```

Aside from "wallet accounts" that only hold SOL, accounts are normally created
by smart contracts (aka programs) so they can store the `data` desired by that
program.
12 changes: 7 additions & 5 deletions docs/toolkit/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: The Solana Toolkit
sidebarSortOrder:
sidebarLabel:
---

> This is a beta version of The Solana Toolkit, and is still a WIP. Please post
Expand All @@ -23,29 +25,29 @@ This toolkit includes tool CLIs:

## Sections

### [Getting Started](getting-started.md)
### Getting Started

To get started with The Solana Toolkit, install the toolkit, configure your
Solana CLI, fund your local keypair.

### [Creating a Project](projects.md)
### Creating a Project

Set up your project with one of the open source scaffolds and templates
available. Each scaffold/template has a different purpose, so be sure to review
all the options explained in this section to pick the most optimal one for your
project.

### [Smart Contract Best Practices](best-practices.md)
### Best Practices

Make sure you're developing Solana smart contracts with best practices like
optimizing compute units, saving bumps, the payer-authority pattern, etc.

### [Test Suite](test-suite.md)
### Test Suite

Use the Solana Test Suite with the `mucho` CLI to have access to tools like a
fuzz tester, code coverage tool, security vulnerability scanner, etc.

### [Running a Local Network](local-testing.md)
### Running a Local Network

Run a local network to be able to build and test with a private and controlled
environment for Solana programs without the need to connect to a public testnet
Expand Down
Loading

0 comments on commit ca036d5

Please sign in to comment.