freeCodeCamp / solana-curriculum

freeCodeCamp Solana Curriculum
BSD 3-Clause "New" or "Revised" License
130 stars 50 forks source link

[HELP]: Error: Invalid secret key in environment variable 'SECRET_KEY'! #364

Open nikaniknin opened 2 months ago

nikaniknin commented 2 months ago

Project: Introduction to cryptography and Solana clients

Lesson Number: https://solana.com/developers/courses/intro-to-solana/intro-to-cryptography, https://solana.com/developers/courses/intro-to-solana/intro-to-writing-data

Question

I learning solana with https://solana.com/developers/courses/intro-to-solana/intro-to-cryptography

I have secret key in .env in format: SECRET_KEY="[(a series of numbers)]"

I installed npm i @solana-developers/helpers

And all other nesessary things

run npx esrun transfer.ts (public key)

got Error:

% npx esrun transfer.ts 4etzwnuNrSbzNeAn27ZoAaywgkEe8aVMxthb3pNWAsH7
/Users/…/node_modules/@solana-developers/helpers/dist/index.js:157
      throw new Error(
            ^

Error: Invalid secret key in environment variable 'SECRET_KEY'!
    at getKeypairFromEnvironment (/Users/…/node_modules/@solana-developers/helpers/dist/index.js:157:13)
    at file:///Users/.../[eval1]:21:21
    at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
    at async ModuleLoader.eval (node:internal/modules/esm/loader:204:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.16.0

BUT In my earlier projects the same operations don’t cause error. I found difference in file /Users/…/node_modules/@solana-developers/helpers/dist/index.js in current (version 2.4) and previous projects (version 2.2).

And If I change file index.js in current project with index.js from older project, everything works (no errors).

What’s wrong with my current index.js? What should I do to make it work without this exchanges?

Code and Screenshots