truffle-init-webpack 项目

本文介绍了一种在使用Truffle框架进行智能合约部署时遇到的常见错误及其解决方案。当尝试运行`truffle migrate`命令时,可能会出现由于未运行Ethereum客户端导致的错误。文章详细说明了如何通过启动testrpc来解决此问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. Usage
    To initialize a project with this exapmple, run truffle init webpack inside an empty directory.

  2. Building and the frontend
    First run truffle compile, then run truffle migrate to deploy the contracts onto your network of choice (default “development”).

    Then run npm run dev to build the app and serve it on http://localhost:8080

直接安装这会出现错误:

nk@ubuntu:~/myProject$ truffle migrate
Error: Invalid JSON RPC response: ""
    at Object.InvalidResponse (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/errors.js:35:16)
    at XMLHttpRequest.request.onreadystatechange (/usr/local/node/lib/node_modules/truffle/node_modules/web3/lib/web3/httpprovider.js:115:32)
    at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:64:18)
    at XMLHttpRequest._setReadyState (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:354:12)
    at XMLHttpRequest._onHttpRequestError (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:544:12)
    at ClientRequest.<anonymous> (/usr/local/node/lib/node_modules/truffle/node_modules/xhr2/lib/xhr2.js:414:24)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at Socket.socketErrorListener (_http_client.js:309:9)
    at emitOne (events.js:96:13)

解决方法:

I figure it out. The reason is because no Ethereum client is running. we just need to run testrpc in another terminal.

另起一终端:
nk@ubuntu:~$ testrpc -a

问题解决.

https://github.com/trufflesuite/truffle-init-webpack
https://github.com/trufflesuite/truffle/issues/393

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值