metaplex-foundation / metaplex

A directory of what the Metaplex Foundation works on!
https://metaplex.com
Apache License 2.0
3.32k stars 6.26k forks source link

[Bug]: Error: bad secret key size #1902

Closed Stevein5280 closed 2 years ago

Stevein5280 commented 2 years ago

Which package is this bug report for?

other

Issue description

I'm not sure what I'm doing wrong

Command

ts-node js/packages/cli/src/candy-machine-v2-cli.ts upload \
    -e devnet \
    -k TWallet_Keypair/public_key.json \
    -cp js/packages/cli/upload-config.json \
    -c example \
    ./assets

Relevant log output

No response

Operating system

MacOS

Priority this issue should have

Medium (should be fixed soon)

Check the Docs First

stegaBOB commented 2 years ago

What is the log output? Not sure what the issue is without the specific error.

Stevein5280 commented 2 years ago

(node:1522) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time (Use node --trace-warnings ... to show where the warning was created) (node:1522) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time /Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/node_modules/tweetnacl/nacl-fast.js:2320 throw new Error('bad secret key size'); ^ Error: bad secret key size at Function.fromSecretKey (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/node_modules/tweetnacl/nacl-fast.js:2320:11) at Function.fromSecretKey (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/node_modules/@solana/web3.js/src/keypair.ts:64:39) at loadWalletKey (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/src/helpers/accounts.ts:595:26) at Command. (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts:132:40) at Command.listener [as _actionHandler] (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:488:17) at /Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1227:65 at Command._chainOrCall (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1144:12) at Command._parseCommand (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1227:27) at Command._dispatchSubcommand /Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1050:25) at Command._parseCommand (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1193:19)

Stevein5280 commented 2 years ago

And When I enter this command without the '.json' on the public_key file here is the command. I have two different files with the public key one in json and the other in plain text. .

ts-node js/packages/cli/src/candy-machine-v2-cli.ts upload \ -e devnet \ -k TWallet_Keypair/public-key \
-cp js/packages/cli/upload-config.json \ -c example \ ./assets

(node:1477) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time (Use node --trace-warnings ... to show where the warning was created) (node:1477) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time /Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/src/helpers/accounts.ts:596 new Uint8Array(JSON.parse(fs.readFileSync(keypair).toString())), ^ SyntaxError: Unexpected token H in JSON at position 0 at JSON.parse () at loadWalletKey (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/src/helpers/accounts.ts:596:25) at Command. (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/src/candy-machine-v2-cli.ts:132:40) at Command.listener [as _actionHandler] (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:488:17) at /Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1227:65 at Command._chainOrCall (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1144:12) at Command._parseCommand (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1227:27) at Command._dispatchSubcommand (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1050:25) at Command._parseCommand (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:1193:19) at Command.parse (/Users/saga/Desktop/Solana-NFT-Generator/metaplex/js/packages/cli/node_modules/commander/lib/command.js:897:10)

stegaBOB commented 2 years ago

That key file has to point to the private key file. The json is invalid. You need to either regenerate it or fix it.

Stevein5280 commented 2 years ago

I appreciate it!

I regenerated a new cli keypair and then tried running the command with the new key pair. . metaplex % ts-node js/packages/cli/src/candy-machine-v2-cli.ts upload \
-e devnet \ -k Demo_Wallet/demo_cli_wallet.json \
-cp js/packages/cli/upload-config.json \ -c example \ ./assets wallet public key: 6QHmXLTajUQJpwmXTRoasNZHsXZnR56DHNJWLeiwgyVa (node:3378) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time (Use node --trace-warnings ... to show where the warning was created) (node:3378) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time Beginning the upload for 5 (img+json) pairs started at: 1646597989506 initializing candy machine Error deploying config to Solana network. Error: Invalid public key input

Stevein5280 commented 2 years ago

On this one I used the private key from the phantom wallet. . metaplex % ts-node js/packages/cli/src/candy-machine-v2-cli.ts upload \ -e devnet \ -k Demo_Wallet/demo_private_key.json \
-cp js/packages/cli/upload-config.json \ -c example \ ./assets (node:3858) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time (Use node --trace-warnings ... to show where the warning was created) (node:3858) ExperimentalWarning: buffer.Blob is an experimental feature. This feature could change at any time /Users/steveninzurriaga/Desktop/Solana-NFT-Generator/metaplex/js/node_modules/tweetnacl/nacl-fast.js:2320 throw new Error('bad secret key size'); ^ Error: bad secret key size

Stevein5280 commented 2 years ago

I have the cli json file in an array how I get it and the private json file in quotations "private key address"

Stevein5280 commented 2 years ago

and here is the upload_config.json file . { "price": 0.01, "number": 5, "gatekeeper": { "gatekeeperNetwork": "ignREusXmGrscGNUesoU9mxfds9AiYTezUKex2PsZV6", "expireOnUse": true }, "solTreasuryAccount": "6QHmXLTajUQJpwmXTRoasNZHsXZnR56DHNJWLeiwgyVa", "splTokenAccount": null, "splToken": null, "goLiveDate": "03 Mar 2022 00:00:00 GMT", "endSettings": null, "whitelistMintSettings": null, "hiddenSettings": null, "storage": "nft-storage", "ipfsInfuraProjectId": null, "ipfsInfuraSecret": null, "awsS3Bucket": null, "nftStorageKey": null, "noRetainAuthority": false, "noMutable": false }

Stevein5280 commented 2 years ago

Any advice tho

github-actions[bot] commented 2 years ago

This Issue has received no activity for 30 days. We will close it in 2 days, please reopen if you are still experiencing this issue.

wajihmsedi commented 2 years ago

@Stevein5280 how to use the same command to mint a token to a public solana address or airdroping the NFT in a given wallet ?

I tried to modify mint.ts and I obtained the same error. That's why I am here.

nischaym commented 2 years ago

anyone found a solution for this ?