15

请教一下truffle如何把合约部署到BSC测试网呢 | 登链社区 | 技术问答

 3 years ago
source link: https://learnblockchain.cn/question/2047
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
请教一下truffle如何把合约部署到BSC测试网呢 | 登链社区 | 技术问答

10 请教一下truffle如何把合约部署到BSC测试网呢

我的truffle-config.js配置如下,但是报错了:

module.exports = {
  networks: {
    development: {
      host: "data-seed-prebsc-1-s1.binance.org", // Localhost (default: none)
      port: 8545,            // Standard Ethereum port (default: none)
      network_id: "*",       // Any network (default: none)
    }
}
Something went wrong while attempting to connect to the network. Check your network configuration.
ProviderError: Invalid JSON RPC response: "<html>\r\n<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n<body>\r\n<center><h1>400 Bad Request</h1></center>\r\n<center>The plain HTTP request was sent to HTTPS port</center>\r\n</body>\r\n</html>\r\n"
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:73:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:102:1
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/src/index.js:111:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
    at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:318:1)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:289:47)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1327:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Truffle v5.1.60 (core: 5.1.60)
Node v14.15.1

最佳答案 2天前

应该是这样:

bsctest: {
provider: function() {
        return new HDWalletProvider(mnemonic, "https://data-seed-prebsc-1-s1.binance.org:8545/")
      },
      network_id: 97,
      gasPrice: 5000000000, 
    },

使用 HDWalletProvider 去链接provider.

还是会报错呢: greeting % truffle migrate

Compiling your contracts...

Everything is up to date, there is nothing to compile.

Something went wrong while attempting to connect to the network. Check your network configuration. ProviderError: Could not connect to your Ethereum client with the following parameters:

  • host > 127.0.0.1
  • port > 7545
  • network_id > 5777 Please check that your Ethereum client:
  • is running
  • is accepting RPC connections (i.e., "--rpc" option is used in geth)
  • is accessible over the network
  • is properly configured in your Truffle configuration file (truffle-config.js)
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:73:1
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:102:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/src/index.js:111:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
at XMLHttpRequest._onHttpRequestError (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:349:1)
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:252:47)
at ClientRequest.emit (events.js:315:20)
at Socket.socketErrorListener (_http_client.js:469:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

Truffle v5.1.60 (core: 5.1.60) Node v14.15.1

还是会报错呢: greeting % truffle migrate

Compiling your contracts...

Everything is up to date, there is nothing to compile.

Something went wrong while attempting to connect to the network. Check your network configuration. ProviderError: Could not connect to your Ethereum client with the following parameters:

  • host > 127.0.0.1
  • port > 7545
  • network_id > 5777 Please check that your Ethereum client:
  • is running
  • is accepting RPC connections (i.e., "--rpc" option is used in geth)
  • is accessible over the network
  • is properly configured in your Truffle configuration file (truffle-config.js)
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:73:1
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:102:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/src/index.js:111:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
at XMLHttpRequest._onHttpRequestError (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:349:1)
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:252:47)
at ClientRequest.emit (events.js:315:20)
at Socket.socketErrorListener (_http_client.js:469:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

Truffle v5.1.60 (core: 5.1.60) Node v14.15.1

还是会报错呢: greeting % truffle migrate

Compiling your contracts...

Everything is up to date, there is nothing to compile.

Something went wrong while attempting to connect to the network. Check your network configuration. ProviderError: Could not connect to your Ethereum client with the following parameters:

  • host > 127.0.0.1
  • port > 7545
  • network_id > 5777 Please check that your Ethereum client:
  • is running
  • is accepting RPC connections (i.e., "--rpc" option is used in geth)
  • is accessible over the network
  • is properly configured in your Truffle configuration file (truffle-config.js)
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:73:1
at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:102:1
at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/src/index.js:111:1)
at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
at XMLHttpRequest._onHttpRequestError (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:349:1)
at ClientRequest.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:252:47)
at ClientRequest.emit (events.js:315:20)
at Socket.socketErrorListener (_http_client.js:469:9)
at Socket.emit (events.js:315:20)
at emitErrorNT (internal/streams/destroy.js:106:8)
at emitErrorCloseNT (internal/streams/destroy.js:74:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)

Truffle v5.1.60 (core: 5.1.60) Node v14.15.1

Tiny熊 - 布道者
擅长:智能合约,以太坊 | 采纳率 39% | 回答于 2天前

其它 1 个回答

wangwei123 2天前

还是会报错呢:

module.exports = {
networks: {
bsctest: {
provider: function() {
return new HDWalletProvider(mnemonic, "https://data-seed-prebsc-1-s1.binance.org:8545/")
},
network_id: 97,
gasPrice: 5000000000,
},
},
mocha: {
// timeout: 100000
},
compilers: {
solc: {
}
}
};
greeting % truffle migrate

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

> Something went wrong while attempting to connect to the network. Check your network configuration.
ProviderError: 
Could not connect to your Ethereum client with the following parameters:
    - host       > 127.0.0.1
    - port       > 7545
    - network_id > 5777
Please check that your Ethereum client:
    - is running
    - is accepting RPC connections (i.e., "--rpc" option is used in geth)
    - is accessible over the network
    - is properly configured in your Truffle configuration file (truffle-config.js)

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:73:1
    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:102:1
    at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3/node_modules/web3-providers-http/src/index.js:111:1)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:1)
    at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:208:1)
    at XMLHttpRequest._onHttpRequestError (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:349:1)
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/node_modules/xhr2-cookies/dist/xml-http-request.js:252:47)
    at ClientRequest.emit (events.js:315:20)
    at Socket.socketErrorListener (_http_client.js:469:9)
    at Socket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
Truffle v5.1.60 (core: 5.1.60)
Node v14.15.1
您需要登录后才可以回答问题,登录 或者 注册

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK