使用solana web3.js连接到本地主机

发布于 2025-02-13 09:23:06 字数 1036 浏览 0 评论 0原文

我正在构建一个微型下一个React应用程序(用于测试目的)来测试我制作的JS脚本,该脚本应该在我的帐户上铸造NFT。我关注 this 使一切都起作用。 但是,当我尝试这两个中的任何一个:

  const connection = new Connection(
    clusterApiUrl('devnet'),
  );

  const connection = new Connection(
    "http://127.0.0.1:8899",
  );

然后我会在创建功能中出现错误:

  let mint = await createMint(
    connection,
    mintRequester,           // payer
    mintRequester.publicKey, // mint
    null,                    // freeze
    0,
  );

错误是:

Unhandled Runtime Error

TypeError: unexpected type, use Uint8Array
Source

scripts/mint.ts (48:4) @ async*_callee$

  46 | 
  47 |   let mint = await createMint(
> 48 |     connection,
     |    ^
  49 |     mintRequester,           // payer
  50 |     mintRequester.publicKey, // mint
  51 |     null,                    // freeze

注意:testNet超时,不能使用它

I'm building a miniature next react app (for test purpose) to test a js script that i made, that is supposed to mint NFT on my account. I'm following this to makes everything works.
But, when i try any of these two:

  const connection = new Connection(
    clusterApiUrl('devnet'),
  );

  const connection = new Connection(
    "http://127.0.0.1:8899",
  );

then i get an error in createMint function:

  let mint = await createMint(
    connection,
    mintRequester,           // payer
    mintRequester.publicKey, // mint
    null,                    // freeze
    0,
  );

the error is:

Unhandled Runtime Error

TypeError: unexpected type, use Uint8Array
Source

scripts/mint.ts (48:4) @ async*_callee$

  46 | 
  47 |   let mint = await createMint(
> 48 |     connection,
     |    ^
  49 |     mintRequester,           // payer
  50 |     mintRequester.publicKey, // mint
  51 |     null,                    // freeze

note: testnet timeout, cant use it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温折酒 2025-02-20 09:23:06

使用localhost时,请确保运行solana-test-validator

Make sure to run solana-test-validator when using localhost.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文