/202204_chainlink-solana-bootcamp

Chainlink Solana Developer Bootcamp 2022/04

Primary LanguageTypeScript

Chainlink - Solana Developer Bootcamp 2022/04

Table Of Contents

Installation

It is assumed vagrant and VirtualBox are already installed on Mac OS

Make sure vagrant has the following plugins (version at the time of writing):

After booting up the VM, the required components such as nodejs, rust, solana will be available.

For completeness:

  • nodejs version: 16.14.2
  • rust version: the latest available
  • solana version: 1.9.5

Editor

Preferred editor is Visual Studio Code (from here onward VSCode). Add extension Remote Development.

Connect to the VM using SSH from inside VSCode. If the VM is not listed on host file $HOME/.ssh/config, add to it from VSCode itself, or manually and then refresh the list.

Open folder to $HOME/project and install Rust and any other helpful extension from inside the VM.

Solana setup

From inside the VM, run Solana commands for checking and updating the configuration.

$ # solana configuration
$ solana config get
Config File: /home/vagrant/.config/solana/cli/config.yml
RPC URL: https://api.mainnet-beta.solana.com 
WebSocket URL: wss://api.mainnet-beta.solana.com/ (computed)
Keypair Path: /home/vagrant/.config/solana/id.json 
Commitment: confirmed

$ # set localhost network
$ solana config set --url localhost
Config File: /home/vagrant/.config/solana/cli/config.yml
RPC URL: http://localhost:8899 
WebSocket URL: ws://localhost:8900/ (computed)
Keypair Path: /home/vagrant/.config/solana/id.json 
Commitment: confirmed

$ # current local wallet
$ solana address
Error: No default signer found, run "solana-keygen new -o /home/vagrant/.config/solana/id.json" to create a new one
$ solana-keygen new
Generating a new keypair

For added security, enter a BIP39 passphrase

NOTE! This passphrase improves security of the recovery seed phrase NOT the
keypair file itself, which is stored as insecure plain text

BIP39 Passphrase (empty for none): 

Wrote new keypair to id-devnet.json
=======================================================================
pubkey: 4hFkodSHRQ5pbQ1RB6BhF4aLHb3mFj8K2oPp8EGk7iCe
=======================================================================
Save this seed phrase and your BIP39 passphrase to recover your new keypair:
actual cause spider robot evoke oven police hunt syrup social rice stem
=======================================================================
$ solana address
BxDS9s2YRihS61kkciUTN5B92z1oNqPEyi7J4BfgSGcc

$ # DON'T run solana-test-validator from inside `project` folder
$ solana-test-validator

From another terminal:

$ solana airdrop 100
Requesting airdrop of 100 SOL

Signature: 21eGD3RAJvChZhUYLm9KV7732MukqFNYe93wi3UG1bQFk61kBNZ71oVH9Ub2BMSnn5WjPivKFoaDKYVtCGpeTyd4

500000100 SOL
$ solana balance
500000100 SOL

Restore pubkey from seed phrase

solana-keygen pubkey prompt://
[seed phrase]
[BIP39 passphrase]

Day 1

Exercises source code from the speaker repo:

Day 2

Exercises source code from the speaker repo:

NOTE

  1. anchor makes use of yarn, replace npm install with yarn add
  2. it is preferred to keep keypairs together, use folder anchor and generate a new keypair like solana-keygen new -o ./anchor/id.json or solana-keygen new -o ./anchor/id-devnet.json.
  3. when requested to export the wallet, go into the folder anchor and run export ANCHOR_WALLET="$(pwd)/id.json"

Resources

Known Issues

  • NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct the issues below and execute "vagrant reload".

    Solution

    (Workaround) Remove entries from /etc/exports.