Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(examples/oft-solana): elaborate #1072

Merged
merged 6 commits into from
Nov 22, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions examples/oft-solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

## Setup

Ensure that you have Rust, Solana, and Anchor installed. If not, follow the instructions in the [official Solana guide](https://solana.com/docs/intro/installation#install-dependencies). On the page as well are instructions on creating a wallet and getting devnet SOL.

We recommend using `pnpm` as a package manager (but you can of course use a package manager of your choice).
Docker is required to build using anchor. We highly recommend that you use the most up-to-date Docker version to avoid any issues with anchor
[Docker](https://docs.docker.com/get-started/get-docker/) is required to build using anchor. We highly recommend that you use the most up-to-date Docker version to avoid any issues with anchor
builds.

### Get the code
Expand All @@ -34,6 +36,41 @@ pnpm install
pnpm test
```

### Get Devnet SOL

```bash
solana airdrop 5 -u devnet
```

We recommend that you request 5 devnet SOL, which should be sufficient for this walkthrough. For the example here, we will be using Solana Devnet. If you are hitting rate limits after, you can also use the [official Solana faucet](https://faucet.solana.com/).
nazreen marked this conversation as resolved.
Show resolved Hide resolved

### Prepare `.env`

```bash
cp .env.example .env
```

In the `.env` just created, set `SOLANA_PRIVATE_KEY` to your private key value in base58 format. Since the locally stored keypair is in an integer array format, we'd need to encode it into base58 first. You can create a temporary script called `getBase58Pk.js` in your project root with the following contents:

```js
import fs from "fs";
import { Keypair } from "@solana/web3.js";
import bs58 from "bs58";

const keypairFilePath = `<KEYPAIR_FILE_PATH_HERE>`; // you can view this by running `solana config get`

const data = fs.readFileSync(keypairFilePath, "utf8");
const keypairJson = JSON.parse(data);
const keypair = Keypair.fromSecretKey(Uint8Array.from(keypairJson));
const base58EncodedPrivateKey = bs58.encode(keypair.secretKey);

console.log(base58EncodedPrivateKey);
```
St0rmBr3w marked this conversation as resolved.
Show resolved Hide resolved

Then, run `node getBase58Pk.js`

Also set the `RPC_URL_SOLANA_TESTNET` value. Note that while the naming used here is `TESTNET`, it refers to the [Solana Devnet](https://docs.layerzero.network/v2/developers/evm/technical-reference/deployed-contracts#solana-testnet). We use `TESTNET` to keep it consistent with the existing EVM testnets.

## Deploy

### Prepare the OFT Program ID
Expand Down Expand Up @@ -73,9 +110,11 @@ Ensure you have Docker running before running the build command.

```bash
anchor build -v # verification flag enabled
solana program deploy --program-id target/deploy/oft-keypair.json target/verifiable/oft.so -u mainnet-beta
solana program deploy --program-id target/deploy/oft-keypair.json target/verifiable/oft.so -u devnet
```

:information_source: the `-u` flag specifies the RPC URL that should be used. The options are `mainnet-beta, devnet, testnet, localhost`, which also have their respective shorthands: `-um, -ud, -ut, -ul`

### Create the OFT

For OFT:
Expand All @@ -84,8 +123,8 @@ For OFT:
pnpm hardhat lz:oft:solana:create --eid 40168 --program-id <PROGRAM_ID>
```

:important: You may specify the `--additional-minters` flag to add a CSV of additional minter keys to the mint
multisig. If you do not want to, you must sepcify `--only-oft-store`. If you choose the latter approach, you can never
:warning: You may specify the `--additional-minters` flag to add a CSV of additional minter keys to the mint
multisig. If you do not want to, you must specify `--only-oft-store true`. If you choose the latter approach, you can never
substitute in a different mint authority.

For OFTAdapter:
Expand All @@ -100,8 +139,8 @@ For OFT Mint-And-Burn Adapter (MABA):
pnpm hardhat lz:oft:solana:create --eid 40168 --program-id <PROGRAM_ID> --mint <TOKEN_MINT> --token-program <TOKEN_PROGRAM_ID>
```

:important: You may specify the `--additional-minters` flag to add a CSV of additional minter keys to the mint
multisig. If you do not want to, you must sepcify `--only-oft-store`. If you choose the latter approach, you can never
:warning: You may specify the `--additional-minters` flag to add a CSV of additional minter keys to the mint
multisig. If you do not want to, you must specify `--only-oft-store store`. If you choose the latter approach, you can never
substitute in a different mint authority.

Make sure to update [layerzero.config.ts](./layerzero.config.ts) and set `solanaContract.address` with the `oftStore` address.
Expand Down
Loading