基于区块链的毕业设计”Quick” Start – “快速”启动
本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计”Quick” Start – “快速”启动 是一篇很好的国外资料
“Quick” Start
Environment variables
First things first, create a file called .env
. It will look something like this.
PORT=3000 MODE="development" LOCAL_NODE="http://localhost:7545" REMOTE_NODE="https://rinkeby.infura.io/v3/<SOME ID>" MNEMONIC = "blah blah blah blah"
LOCAL_NODE
is the address of a local blockchain you’re going to run.
REMOTE_NODE
refers to the one you’re going to deploy to remotely. Probably a test network, the main Ethereum net is probably too expensive to make this deploy worthwhile. You can get an endpoint to deploy from via https://infura.io/register.
The MNEMONIC
is the mnemonic for accessing the wallet you’ll use to pay the gas for deploying the contract on a remote node like Rinkeby. Make sure that wallet has enough ETH in it.
Deploy to a local blockchain
- Install Ganache
- Start Ganache and do “Quickstart”
- Run
npm start
- Run
truffle migrate
in this directory - You should see two mirations. The one called
1609276627_conways_game_of_life
should have acontract address:
– copy down the value somewhere.
Deploy to rinkeby
- Run
truffle migrate --network rinkeby
- You should see two mirations. The one called
1609276627_conways_game_of_life
should have acontract address:
– copy down the value somewhere.
Start the web app
npm install
Then in one shell run npm start
and npm run webpack
in another.
Go to http://localhost:3000 and you should see the board.
Get onto the console
- Go to
truffle develop
/truffle console --network rinkeby
let instance = await ConwaysGameOfLife.deployed() let accounts = await web3.eth.getAccounts() // Set this to whatever the contract address from `migrate` was let contractAddress = '0x0aAd3D96a59806f9FE651Ab4a52E8F82b934DE45' // Let's send the contract some ETH await web3.eth.sendTransaction({to: contractAddress, from: accounts[0], value: 1000000000000000, gas: 300722130000}) // This should show you what the world currently looks like instance.getWorld() instance.world.call() // Make sure it has some ETH to pay the gas costs of `getWorld` web3.eth.getBalance(contractAddress) // Make sure the address we are using has ETH web3.eth.getBalance(accounts[0]) // Send the exact right amount to step the world, and make sure the gas price is high enough web3.eth.sendTransaction({to: contractAddress, from: accounts[0], value: 10000000000000, gas: 3000000}) // Check the world again instance.getWorld()
Optimisation
V0.0.2
- Changed optimise for solc to 200 runs
- Using uint8 for numLiveNeighbours
- Worldlength up top
Typical Gas Price: 402278 somehow higher
V0.0.1
Typical Gas Price: 276482
快速启动
环境变量
首先,创建一个名为.env的文件。它看起来像这样。
PORT=3000 MODE="development" LOCAL_NODE="http://localhost:7545" REMOTE_NODE="https://rinkeby.infura.io/v3/<SOME ID>" MNEMONIC = "blah blah blah blah"
LOCALu NODE是您要运行的本地区块链blockchain的地址。
远程u节点是指您要远程部署到的节点。可能是一个测试网络,主要以太坊eth网络可能太贵,使这个部署值得。您可以通过获取要部署的端点https://infura.io/register。
助记符是访问钱包的助记符,您将使用钱包支付在远程节点(如Rinkeby)部署合同的费用。确保钱包里有足够的钱。
部署到本地区块链blockchain
- 安装Ganache
- 启动Ganache执行“快速启动”
- 运行npm start
- 运行truffle migrate在这个目录中
- 您应该会看到两个幻象。一个叫1609276627u conwaysu gameu ofu life的应该有一个合同地址:-把价值复制到某个地方。你应该看到两个幻象。一个叫1609276627u conwaysu gameu ofu life的应该有一个合同地址:-把价值复制到某个地方。转到truffle develop/truffle console—network rinkeby,将solc的优化设置更改为200次,使用uint8进行numLiveNeighbours
部署到rinkeby
- Run
truffle migrate --network rinkeby
- You should see two mirations. The one called
1609276627_conways_game_of_life
should have acontract address:
– copy down the value somewhere.
启动web应用
npm install
然后在一个shell中运行npm start,在另一个shell中运行npm webpack。
转到http://localhost:3000,你应该看到黑板。
进入控制台
- Go to
truffle develop
/truffle console --network rinkeby
let instance = await ConwaysGameOfLife.deployed() let accounts = await web3.eth.getAccounts() // Set this to whatever the contract address from `migrate` was let contractAddress = '0x0aAd3D96a59806f9FE651Ab4a52E8F82b934DE45' // Let's send the contract some ETH await web3.eth.sendTransaction({to: contractAddress, from: accounts[0], value: 1000000000000000, gas: 300722130000}) // This should show you what the world currently looks like instance.getWorld() instance.world.call() // Make sure it has some ETH to pay the gas costs of `getWorld` web3.eth.getBalance(contractAddress) // Make sure the address we are using has ETH web3.eth.getBalance(accounts[0]) // Send the exact right amount to step the world, and make sure the gas price is high enough web3.eth.sendTransaction({to: contractAddress, from: accounts[0], value: 10000000000000, gas: 3000000}) // Check the world again instance.getWorld()
优化
- Changed optimise for solc to 200 runs
- Using uint8 for numLiveNeighbours
- Worldlength up top
典型天然气价格:402278略高🤔
典型天然气价格:276482
- Changed optimise for solc to 200 runs
- Using uint8 for numLiveNeighbours
- Worldlength up top
典型天然气价格:402278略高🤔
典型天然气价格:276482
典型天然气价格:276482
部分转自网络,侵权联系删除区块链源码网
区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计”Quick” Start – “快速”启动