以太坊Webpack示例Dapp
带有Webpack的示例以太坊(Solidity)智能合约去中心化应用程序,展示了以下功能和行为:
- 简单的以太坊去中心化应用程序(dapp),具有:
- 用Solidity编写的智能合约
- 一个使用Vanilla JavaScript编写的简单查看器。
- 最小的改造。仅使用前端JavaScript开发人员已经熟悉的工具。
- 智能合约基于ethereum.org上的教程中的 The Coin 。
- 通过solc-loader和web3-loader通过Webpack直接导入Solidity代码并实例化智能合约。
- 与智能合约的接口非常简单
import { MyToken } from './contract/MyToken.sol'
。 - 请参阅
index.js
以获取更多详细信息。
- 与智能合约的接口非常简单
- 是用于创建以太坊去中心化应用程序的简单入门套件。
# Using testrpc (recommended) testrpc # If you are running Geth, # make sure to run in testnet or private net and enable rpc geth --testnet --rpc
- Install dependencies
npm install
- Run, during development
npm start
Once webpack build is done, open index.html
in your favorite web browser.
Webpack is now started in --watch
mode, any changes done at JavaScript or Solidity files would automatically rebuild the affected modules.
- Build, for deployment
npm run build
Only the static
directory is required to be hosted and served.
- Run tests
npm test
Additional notes
-
web3-loader can be further configured, for example to reuse a deployed contract instead of redeploying at every build. See web3-loader's README for more details.
-
Similarly for solc-loader.