diff --git a/examples/oft-solana/README.md b/examples/oft-solana/README.md index 77c91f459..ad3116952 100644 --- a/examples/oft-solana/README.md +++ b/examples/oft-solana/README.md @@ -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 @@ -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 hit RPC rate limits after, you can also use the [official Solana faucet](https://faucet.solana.com/). + +### 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 = ``; // 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); +``` + +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 @@ -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: @@ -84,8 +123,8 @@ For OFT: pnpm hardhat lz:oft:solana:create --eid 40168 --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: @@ -100,8 +139,8 @@ For OFT Mint-And-Burn Adapter (MABA): pnpm hardhat lz:oft:solana:create --eid 40168 --program-id --mint --token-program ``` -: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.