Skip to content

Commit

Permalink
Merge pull request #31 from solana-foundation/docs-migration
Browse files Browse the repository at this point in the history
[docs] docs migration
  • Loading branch information
nickfrosty authored Dec 11, 2023
2 parents 83016a3 + 26c5407 commit 39b6c25
Show file tree
Hide file tree
Showing 156 changed files with 9,435 additions and 2,448 deletions.
5 changes: 5 additions & 0 deletions docs/advanced/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
metaOnly: true
title: Advanced Concepts
# sidebarSortOrder: 3
---
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ efficiently load more addresses in a single transaction.
Since each transaction on the Solana blockchain requires a listing of every
address that is interacted with as part of the transaction, this listing would
effectively be capped at 32 addresses per transaction. With the help of
[Address Lookup Tables](./lookup-tables.md), a transaction would now be able to
raise that limit to 256 addresses per transaction.
[Address Lookup Tables](/docs/advanced/lookup-tables.md), a transaction would
now be able to raise that limit to 256 addresses per transaction.

## Compressing on chain addresses

Expand All @@ -27,7 +27,7 @@ table for use inside any given transaction.

To utilize an Address Lookup Table inside a transaction, developers must use v0
transactions that were introduced with the new
[Versioned Transaction format](./versioned-transactions.md).
[Versioned Transaction format](/docs/core/transactions/versions.md).

## How to create an address lookup table

Expand Down Expand Up @@ -65,7 +65,7 @@ console.log("lookup table address:", lookupTableAddress.toBase58());
> NOTE: Address lookup tables can be **created** with either a `v0` transaction
> or a `legacy` transaction. But the Solana runtime can only retrieve and handle
> the additional addresses within a lookup table while using
> [v0 Versioned Transactions](./versioned-transactions.md#current-transaction-versions).
> [v0 Versioned Transactions](/docs/core/transactions/versions.md#current-transaction-versions).
## Add addresses to a lookup table

Expand Down Expand Up @@ -141,9 +141,9 @@ chain (via extending the lookup table), you can create a `v0` transaction to
utilize the on chain lookup capabilities.

Just like older `legacy` transactions, you can create all the
[instructions](./../terminology.md#instruction) your transaction will execute on
chain. You can then provide an array of these instructions to the
[Message](./../terminology.md#message) used in the `v0 transaction.
[instructions](/docs/terminology.md#instruction) your transaction will execute
on chain. You can then provide an array of these instructions to the
[Message](/docs/terminology.md#message) used in the `v0 transaction.

> NOTE: The instructions used inside a `v0` transaction can be constructed using
> the same methods and functions used to create the instructions in the past.
Expand Down Expand Up @@ -183,6 +183,7 @@ console.log(
## More Resources

- Read the [proposal](./../proposals/versioned-transactions.md) for Address
Lookup Tables and Versioned transactions
- Read the
[proposal](https://docs.solanalabs.com/proposals/versioned-transactions) for
Address Lookup Tables and Versioned transactions
- [Example Rust program using Address Lookup Tables](https://github.com/TeamRaccoons/address-lookup-table-multi-swap)
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ description:
accounts.'
---

On Solana, [State Compression](./state-compression.md) is the method of creating
a "fingerprint" (or hash) of off-chain data and storing this fingerprint
on-chain for secure verification. Effectively using the security of the Solana
ledger to securely validate off-chain data, verifying it has not been tampered
with.
On Solana, [State Compression](/docs/advanced/state-compression.md) is the
method of creating a "fingerprint" (or hash) of off-chain data and storing this
fingerprint on-chain for secure verification. Effectively using the security of
the Solana ledger to securely validate off-chain data, verifying it has not been
tampered with.

This method of "compression" allows Solana programs and dApps to use cheap
blockchain [ledger](./../terminology.md#ledger) space, instead of the more
expensive [account](./../terminology.md#account) space, to securely store data.
blockchain [ledger](/docs/terminology.md#ledger) space, instead of the more
expensive [account](/docs/terminology.md#account) space, to securely store data.

This is accomplished by using a special binary tree structure, known as a
[concurrent merkle tree](#what-is-a-concurrent-merkle-tree), to create a hash of
Expand Down Expand Up @@ -82,19 +82,15 @@ and effectively invalidates the previous root hash and previous proof.
Therefore, each change to these _traditional merkle trees_ are required to be
performed in series.

:::info

This process of changing leaf data, and computing a new root hash can be a
**very common** thing when using merkle trees! While it is one of the design
points of the tree, it can result in one of the most notable drawbacks: rapid
changes.

:::
> This process of changing leaf data, and computing a new root hash can be a
> **very common** thing when using merkle trees! While it is one of the design
> points of the tree, it can result in one of the most notable drawbacks: rapid
> changes.
### What is a Concurrent merkle tree?

In high throughput applications, like within the
[Solana runtime](/src/validator/runtime.md), requests to change an on-chain
[Solana runtime](/docs/core/runtime.md), requests to change an on-chain
_traditional merkle tree_ could be received by validators in relatively rapid
succession (e.g. within the same slot). Each leaf data change would still be
required to performed in series. Resulting in each subsequent request for change
Expand Down Expand Up @@ -136,7 +132,7 @@ Therefore, the `maxDepth` of a tree is used to determine the maximum number of
nodes (aka pieces of data or `leafs`) to store within the tree using a simple
calculation:

```
```text
nodes_count = 2 ^ maxDepth
```

Expand All @@ -149,7 +145,7 @@ above, you can determine the lowest `maxDepth` to store your data.
If you wanted to create a tree to store 100 compressed nfts, we will need a
minimum of "100 leafs" or "100 nodes".

```
```text
// maxDepth=6 -> 64 nodes
2^6 = 64
Expand All @@ -164,7 +160,7 @@ We must use a `maxDepth` of `7` to ensure we can store all of our data.
If you wanted to create a tree to store 15000 compressed nfts, we will need a
minimum of "15000 leafs" or "15000 nodes".

```
```text
// maxDepth=13 -> 8192 nodes
2^13 = 8192
Expand Down Expand Up @@ -257,7 +253,7 @@ used to calculate the on-chain storage (in bytes) required for a tree to exist
on chain.

Once the required space (in bytes) has been calculated, and using the
[`getMinimumBalanceForRentExemption`](/api/http#getminimumbalanceforrentexemption)
[`getMinimumBalanceForRentExemption`](/docs/rpc/http/getminimumbalanceforrentexemption)
RPC method, request the cost (in lamports) to allocate this amount of bytes
on-chain.

Expand Down Expand Up @@ -325,9 +321,6 @@ Compressed NFTs are one of the most popular use cases for State Compression on
Solana. With compression, a one million NFT collection could be minted for
`~50 SOL`, vice `~12,000 SOL` for its uncompressed equivalent collection.

:::info Developer Guide

Read our developer guide for
[minting and transferring compressed NFTs](./../developing/guides/compressed-nfts).

:::
If you are interested in creating compressed NFTs yourself, read our developer
guide for
[minting and transferring compressed NFTs](/content/guides/javascript/compressed-nfts.md).
5 changes: 5 additions & 0 deletions docs/clients/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
metaOnly: true
title: Solana Clients
# sidebarSortOrder: 3
---
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Web3 API Reference
title: Web3.js API Examples
---

## Web3 API Reference Guide

The `@solana/web3.js` library is a package that has coverage over the
[Solana JSON RPC API](/api).
[Solana JSON RPC API](/docs/rpc).

You can find the full documentation for the `@solana/web3.js` library
[here](https://solana-labs.github.io/solana-web3.js/).
Expand All @@ -16,8 +16,8 @@ You can find the full documentation for the `@solana/web3.js` library

[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/Connection.html)

Connection is used to interact with the [Solana JSON RPC](/api). You can use
Connection to confirm transactions, get account info, and more.
Connection is used to interact with the [Solana JSON RPC](/docs/rpc). You can
use Connection to confirm transactions, get account info, and more.

You create a connection by defining the JSON RPC cluster endpoint and the
desired commitment. Once this is complete, you can use this connection object to
Expand Down Expand Up @@ -64,7 +64,7 @@ for the full list.

### Transaction

[SourceDocumentation](https://solana-labs.github.io/solana-web3.js/classes/Transaction.html)
[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/Transaction.html)

A transaction is used to interact with programs on the Solana blockchain. These
transactions are constructed with TransactionInstructions, containing all the
Expand Down Expand Up @@ -257,7 +257,7 @@ console.log(`Valid Program Address: ${validProgramAddress}`);

### SystemProgram

[SourceDocumentation](https://solana-labs.github.io/solana-web3.js/classes/SystemProgram.html)
[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/SystemProgram.html)

The SystemProgram grants the ability to create accounts, allocate account data,
assign an account to programs, work with nonce accounts, and transfer lamports.
Expand Down Expand Up @@ -422,8 +422,8 @@ await web3.sendAndConfirmTransaction(connection, transaction, [fromPublicKey]);

Message is used as another way to construct transactions. You can construct a
message using the accounts, header, instructions, and recentBlockhash that are a
part of a transaction. A [Transaction](javascript-api.md#Transaction) is a
Message plus the list of required signatures required to execute the
part of a transaction. A [Transaction](/docs/clients/javascript.md#Transaction)
is a Message plus the list of required signatures required to execute the
transaction.

#### Example Usage
Expand Down Expand Up @@ -484,7 +484,7 @@ await web3.sendAndConfirmTransaction(connection, transaction, [fromPublicKey]);

### Struct

[SourceDocumentation](https://solana-labs.github.io/solana-web3.js/classes/Struct.html)
[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/Struct.html)

The struct class is used to create Rust compatible structs in javascript. This
class is only compatible with Borsh encoded Rust structs.
Expand Down Expand Up @@ -519,8 +519,8 @@ export class Fee extends Struct {
The Enum class is used to represent a Rust compatible Enum in javascript. The
enum will just be a string representation if logged but can be properly
encoded/decoded when used in conjunction with
[Struct](javascript-api.md#Struct). This class is only compatible with Borsh
encoded Rust enumerations.
[Struct](/docs/clients/javascript.md#Struct). This class is only compatible with
Borsh encoded Rust enumerations.

#### Example Usage

Expand Down Expand Up @@ -634,7 +634,7 @@ offline with the nonce in place of the `recentBlockhash`.

### VoteAccount

[SourceDocumentation](https://solana-labs.github.io/solana-web3.js/classes/VoteAccount.html)
[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/VoteAccount.html)

Vote account is an object that grants the capability of decoding vote accounts
from the native vote account program on the network.
Expand Down Expand Up @@ -708,7 +708,7 @@ VoteAccount {

### StakeProgram

[SourceDocumentation](https://solana-labs.github.io/solana-web3.js/classes/StakeProgram.html)
[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/StakeProgram.html)

The StakeProgram facilitates staking SOL and delegating them to any validators
on the network. You can use StakeProgram to create a stake account, stake some
Expand Down Expand Up @@ -815,17 +815,17 @@ within Solana. You can designate a `staker` and `withdrawer` separately,
allowing for a different account to withdraw other than the staker.

You can find more usage of the `Authorized` object under
[`StakeProgram`](javascript-api.md#StakeProgram)
[`StakeProgram`](/docs/clients/javascript.md#StakeProgram)

### Lockup

[Source Documentation](https://solana-labs.github.io/solana-web3.js/classes/Lockup.html)

Lockup is used in conjunction with the
[StakeProgram](javascript-api.md#StakeProgram) to create an account. The Lockup
is used to determine how long the stake will be locked, or unable to be
retrieved. If the Lockup is set to 0 for both epoch and the Unix timestamp, the
lockup will be disabled for the stake account.
[StakeProgram](/docs/clients/javascript.md#StakeProgram) to create an account.
The Lockup is used to determine how long the stake will be locked, or unable to
be retrieved. If the Lockup is set to 0 for both epoch and the Unix timestamp,
the lockup will be disabled for the stake account.

#### Example Usage

Expand Down Expand Up @@ -855,4 +855,4 @@ The above code creates a `createStakeAccountInstruction` to be used when
creating an account with the `StakeProgram`. The Lockup is set to 0 for both the
epoch and Unix timestamp, disabling lockup for the account.

See [StakeProgram](javascript-api.md#StakeProgram) for more.
See [StakeProgram](/docs/clients/javascript.md#StakeProgram) for more.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
---
title: Web3 JavaScript API
sidebarLabel: JavaScript / TypeScript
title: JavaScript Client for Solana
sidebarSortOrder: 2
---

## What is Solana-Web3.js?

The Solana-Web3.js library aims to provide complete coverage of Solana. The
library was built on top of the [Solana JSON RPC API](/api).
library was built on top of the [Solana JSON RPC API](/docs/rpc).

You can find the full documentation for the `@solana/web3.js` library
[here](https://solana-labs.github.io/solana-web3.js/).
Expand All @@ -19,7 +21,7 @@ You can find the full documentation for the `@solana/web3.js` library
| Transaction | One or more instructions signed by the client using one or more Keypairs and executed atomically with only two possible outcomes: success or failure. |

For the full list of terms, see
[Solana terminology](../../terminology#cross-program-invocation)
[Solana terminology](/docs/terminology.md#cross-program-invocation-cpi)

## Getting Started

Expand All @@ -28,13 +30,13 @@ For the full list of terms, see
#### yarn

```bash
$ yarn add @solana/web3.js
yarn add @solana/web3.js
```

#### npm

```bash
$ npm install --save @solana/web3.js
npm install --save @solana/web3.js
```

#### Bundle
Expand Down Expand Up @@ -125,8 +127,8 @@ order that instructions exist in a transaction determines the order they are
executed.

A transaction in Solana-Web3.js is created using the
[`Transaction`](javascript-api.md#Transaction) object and adding desired
messages, addresses, or instructions.
[`Transaction`](/docs/clients/javascript.md#Transaction) object and adding
desired messages, addresses, or instructions.

Take the example of a transfer transaction:

Expand Down
6 changes: 4 additions & 2 deletions docs/developing/clients/rust-api.md → docs/clients/rust.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
title: Rust API
sidebarLabel: Rust
title: Rust Client for Solana
sidebarSortOrder: 1
---

Solana's Rust crates are [published to crates.io][crates.io] and can be found
Expand All @@ -19,7 +21,7 @@ Some important crates:
that do not run on-chain will import this.

- [`solana-client`] — For interacting with a Solana node via the
[JSON RPC API](/api).
[JSON RPC API](/docs/rpc).

- [`solana-cli-config`] — Loading and saving the Solana CLI configuration
file.
Expand Down
Loading

0 comments on commit 39b6c25

Please sign in to comment.