Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

[Bug]: Course Chapter 1, Page 3 has unclear and not correct code example #44

@Noxdor

Description

@Noxdor

Describe the bug:
I am talking about this page: https://www.soldev.app/course/intro-to-writing-data

In the Lab section, you can find the following code example which I annotated with comments where I think the block could be improved:

import * as web3 from "@solana/web3.js";
import * as dotenv from "dotenv";
import base58 from "bs58"; // not actually used here (neither in the next block), can be removed
import { getKeypairFromEnvironment } from "@solana-developers/node-helpers"
const toPubkey = new PublicKey(suppliedToPubkey); // suppliedToPubkey is nowhere defined. Maybe show an example with a generated pub key here as in the first tutorial

dotenv.config(); // with es module syntax, it's actually better to just import dotenv/config

const senderKeypair = getKeypairFromEnvironment("SECRET_KEY");

const connection = new Connection("https://api.devnet.solana.com", "confirmed");


console.log(`✅ Loaded our own keypair, the destination public key, and connected to Solana`);

This is what I would suggest the code to update to:

import "dotenv/config"
import { Connection, clusterApiUrl, Keypair } from "@solana/web3.js"
import { getKeypairFromEnvironment } from "@solana-developers/node-helpers"

const { publicKey: toPubkey } = new Keypair()
const senderKeypair = getKeypairFromEnvironment("SECRET_KEY")

const connection = new Connection(clusterApiUrl("devnet"))

console.log(
  `✅ Loaded our own keypair, the destination public key, and connected to Solana`,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions