【问题标题】:Solana Tic-Tac-Toe Game - Bad secret key sizeSolana 井字游戏 - 错误的密钥大小
【发布时间】:2022-12-04 07:14:37
【问题描述】:

我克隆了一个井字游戏存储库来理解智能合约和 Rust 的逻辑。它在 moralis 上工作,需要两个玩家钱包地址来玩/创建游戏,但是当我添加第二个 Phantom 钱包时(它们都是我的钱包,但地址不同)我收到此错误:


wait  - compiling /api/TicTacToe/newGame...
event - compiled successfully in 101 ms (51 modules)
error - Error: bad secret key size
    at Function.fromSecretKey (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/@solana/web3.js/lib/index.cjs.js:7497:13)
    at handler (webpack-internal:///(api)/./pages/api/TicTacToe/newGame.ts:23:74)
    at Object.apiResolver (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/next/dist/server/api-utils/node.js:184:15)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async DevServer.runApi (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/next/dist/server/next-server.js:403:9)
    at async Object.fn (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/next/dist/server/base-server.js:493:37)
    at async Router.execute (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/next/dist/server/router.js:222:36)
    at async DevServer.run (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/next/dist/server/base-server.js:612:29)
    at async DevServer.run (/home/aleyna/tmp/solana-smart-contract-tic-tac-toe/node_modules/next/dist/server/dev/next-dev-server.js:569:20) {
  page: '/api/TicTacToe/newGame'
}



我可以理解问题与我的密钥大小有关,但我不知道如何解决。

【问题讨论】:

    标签: blockchain smartcontracts solana solana-web3js moralis


    【解决方案1】:

    看起来问题出在您使用的密钥上。在错误消息中,它表示密钥大小错误。在代码中,密钥似乎是从 newGame.ts 文件第 23 行的 secrets 对象中获取的。确保您使用的密钥大小和格式正确。

    如果您不确定正确的密钥大小和格式应该是什么,您可以查看用于管理密钥的库的文档(在本例中,它看起来像 @solana/web3.js)。该文档应提供有关如何生成和使用库的密钥的信息。

    如果您仍然遇到问题,分享 newGame.ts 文件的代码以及任何其他相关代码和配置可能会有所帮助,以便我们仔细研究并提供更具体的建议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-31
      相关资源
      最近更新 更多