buildspace课程学习疑难问题解决
January 5th, 2022

本人MAC环境

1、Build a Web3 app on Solana with React and Rust

  • section3 Install Solana,执行solana-test-validator,报错
“Failed to get validator identity over RPC: error sending request for url (http://127.0.0.1:8899/): operation timed out”

解决方法:sudo solana-test-validator

后面的anchor命令执行时如果报错,也可以加sudo试一下。

过程分析:在网上查找资料,发现localhost和127.0.0.1还是有点区别的,

图1
图1

看到权限问题,突然灵机一动,想会不会是用户权限问题,通过执行 sudo solana-test-validator,就可以测试通过。

  • section4 Setup a Solana provider on our web app

在import '@solana/web3.js' 和 '@project-serum/anchor'后,报错

index.js:36 Uncaught ReferenceError: global is not defined

解决方法:修改vite.config.js文件

export default({
  plugins: [reactRefresh()],
  server: {
    host: '0.0.0.0',
    hmr: {
      port: 443,
    }
  },
  define:{
    global: {},
    process: {
      'env': {}
    }
  }
})
  • section3 Submitting GIFs to Solana program.

提交git链接时报错,

Error sending GIF: ReferenceError: Buffer is not defined

解决方法:在app.jsx里面增加以下代码

import { Buffer } from 'buffer';
window.Buffer = Buffer;

2、Build your own DAO with just Javascript in a weekend

此问题还未彻底解决,暂时规避。

在本地电脑端执行 node scripts/2-deploy-drop.js 命令,出错,

failed to deploy bundleDrop module FetchError: request to https://cloudflare-ipfs.com/ipfs/bafkreiefkcmnhijabnix2gjjgwfenphlztyyltdrnnignxn2lfnvv33saq failed, reason: connect ETIMEDOUT 157.240.12.35:443

主要原因是国内无法访问cloudflare-ipfs.com,需要通过梯子访问。换了一个国内可以访问的节点,加到 1-initialize-sdk.js里面,

const sdk = new ThirdwebSDK(
  new ethers.Wallet(
    // Your wallet private key. ALWAYS KEEP THIS PRIVATE, DO NOT SHARE IT WITH ANYONE, add it to your .env file and do not commit that file to github!
    process.env.PRIVATE_KEY,
    // RPC URL, we'll use our Alchemy API URL from our .env file.
    ethers.getDefaultProvider(process.env.ALCHEMY_API_URL),
  ),{ ipfsGatewayUrl: "https://ipfs.kxv.io" }
);

会报出另外一个错,

failed to deploy bundleDrop module TypeError: body used already for: https://ipfs.kxv.io/bafkreibttvf473lykpv62poikaubmkl4l4s7j2qsqwaihgmu5oxa2zmn3m

分析应该还是节点问题,还不清楚怎么彻底解决。

目前只能将代码在replit平台里面执行成功,暂时规避。

Subscribe to mutou love study
Receive the latest updates directly to your inbox.
Verification
This entry has been permanently stored onchain and signed by its creator.
More from mutou love study

Skeleton

Skeleton

Skeleton