typeError:_bundlr_network_client__webpack_imported_module_0__使用metaplex.nfts()。
我正在使用 this metaplex javascript javascript SDK与NFTS一起工作Solana区块链。
在上传NFT的元数据时,我会收到以下错误: typeError:_bundlr_network_client_webpack_imported_module_0__不是构造
函数用于连接到metaplex的代码:
const fromWallet = Keypair.generate();
console.log(fromWallet);
const connection = new Connection(clusterApiUrl("devnet"));
const metaplex = Metaplex.make(connection)
.use(keypairIdentity(fromWallet))
.use(
bundlrStorage({
address: "https://devnet.bundlr.network",
providerUrl: "https://api.devnet.solana.com",
timeout: 60000,
})
);
上传元数据函数:
async function uploadMetadata() {
try {
const { uri, metadata } = await metaplex.nfts().uploadMetadata({
name: formInput.name,
image: image,
description: formInput.description,
});
console.log(metadata.image);
return uri;
} catch (error) {
console.log(`Error uploading metadata - ${error}`);
}
}
我无法理解为什么会遇到此错误。我试图通过从Metaplex配置中删除(Kepairidentity(Fromwallet))来达到该功能。但是,这样我就遇到了另一个错误。对于Metaplex的类似配置,mx.nfts()。findnftbymint(new publicKey(地址))正常工作。
任何帮助都将受到赞赏。谢谢。
I'm using this metaplex javascript SDK for working with nfts on solana blockchain.
While uploading the metadata for an nft, I am getting the following error:TypeError: _bundlr_network_client__WEBPACK_IMPORTED_MODULE_0__ is not a constructor
Code for connecting to metaplex:
const fromWallet = Keypair.generate();
console.log(fromWallet);
const connection = new Connection(clusterApiUrl("devnet"));
const metaplex = Metaplex.make(connection)
.use(keypairIdentity(fromWallet))
.use(
bundlrStorage({
address: "https://devnet.bundlr.network",
providerUrl: "https://api.devnet.solana.com",
timeout: 60000,
})
);
Uploading metadata function:
async function uploadMetadata() {
try {
const { uri, metadata } = await metaplex.nfts().uploadMetadata({
name: formInput.name,
image: image,
description: formInput.description,
});
console.log(metadata.image);
return uri;
} catch (error) {
console.log(`Error uploading metadata - ${error}`);
}
}
I couldn't understand why I'm getting this error. I tried to hit the function by removing .use(keypairIdentity(fromWallet)) from metaplex configuration. But I am getting another error regarding undefined wallet that way. For the similar configuration of metaplex, mx.nfts().findNftByMint(new PublicKey(address)) is working correctly.
Any help is appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我正面临完全相同的问题
我在metaplex github repo https://github.com/metaplex-foundation/138“ js/essess/138
所以事实证明我们需要使用钱包适配器
Kepairidentity& WalletAdapterIdentity应该在浏览器上工作,但是只有Walletapteridentity对我有用。
Metaplex也创建的钱包适配器的链接是 https://github.com/solana-labs/钱包 - 适配器
更新,您只需要包装应用程序组件
和MintInterface组件,
请确保在配置中使用WalletAdapterIdentity
I was facing the exact same issue
I opened an issue on metaplex github repo https://github.com/metaplex-foundation/js/issues/138
so it turned out we need to use the wallet adapter
keypairIdentity & walletAdapterIdentity should work on the browser however only walletAdapterIdentity worked for me .
the link to wallet adapter also created by metaplex is https://github.com/solana-labs/wallet-adapter
update, you just need to wrap you app component
and in the MintInterface Component
make sure you use walletAdapterIdentity in the configuration