ubuntu abortHandshake(this,req,'意外的服务器响应:${相对状态代码}“);- - linq 比

2ledvvac  于 2023-01-12  发布在  其他
关注(0)|答案(1)|浏览(92)

我尝试在Windows上使用Ubuntu运行truffle迁移:

每次我编译合同的时候都失败了。使用truffle migrate --network rinkeby

结果显示:

Compiling your contracts...
===========================
> Compiling ./contracts/DaMiToken.sol
> Artifacts written to /home/yy/Cfunding/build/contracts
> Compiled successfully using:
   - solc: 0.8.11+commit.d7f03943.Emscripten.clang

/home/yy/Cfunding/node_modules/ws/lib/websocket.js:542
    abortHandshake(this, req, `Unexpected server response: ${res.statusCode}`);
    ^
Error: Unexpected server response: 401
    at ClientRequest.<anonymous> (/home/yy/Cfunding/node_modules/ws/lib/websocket.js:542:5)
    at ClientRequest.emit (node:events:527:28)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:639:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:117:17)
    at TLSSocket.socketOnData (node:_http_client:502:22)
    at TLSSocket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)
    at readableAddChunk (node:internal/streams/readable:297:9)
    at TLSSocket.Readable.push (node:internal/streams/readable:234:10)
    at TLSWrap.onStreamRead (node:internal/stream_base_commons:190:23)

我不知道这个问题的解决方案。我的truffle-config.js代码是:

const HDWalletProvider = require('@truffle/hdwallet-provider');
var privateKey = process.env.privateKey;
var infuraId = process.env.infuraId;

module.exports = {

  networks: {
    rinkeby: {
      provider: () => new HDWalletProvider("9782e**23", "wss://rinkeby.infura.io/ws/v3/****"),
      gas: 10000000, 
      gasPrice: 15000000000,
      network_id: 4,  
      timeoutBlocks: 40000, 
    },
  },
  mocha: {
    // timeout: 100000
  },

  compilers: {
    solc: {
      version: "0.8.11",      // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      settings: {          // See the solidity docs for advice about optimization and evmVersion
        optimizer: {
          enabled: true,
          runs: 200      
        },
        evmVersion: "london"
      }
    }
  },
};
gojuced7

gojuced71#

Rinkeby testnet已弃用,自infura.io2022年10月起www.example.com不再提供支持。请使用goerli网络部署您的合约。将以下代码放入truffle.config文件中

goerli: {
      provider: () => new HDWalletProvider('Your Seed Phrase', `https://goerli.infura.io/v3/Your_infura_id`),
      network_id: 5,     
      gas: 8000000,        
      timeoutBlocks: 200,  
    },

和运行命令
truffle迁移--重置合同文件。sol --网络goerli

相关问题