部署需要消耗Gas,获取测试以太币用于部署
部署智能合约
验证部署
0x29920e756f41F8e691aE0b12D417C19204371E91
truffle migrate--network kovan
G:\qikegu\ethereum\mydapp>truffle migrate--network kovan
Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Migrations dry-run (simulation)
===============================
> Network name: 'kovan-fork'
> Network id: 42
> Block gas limit: 0x7a1200
...
Starting migrations...
======================
> Network name: 'kovan'
> Network id: 42
> Block gas limit: 0x7a1200
1_initial_migration.js
======================
Deploying 'Migrations'
----------------------
> transaction hash: 0x7e30b5c716afed45888a9dd2d6af7e6f52a9fade0346e8ad7d0c268de508a26a
> Blocks: 2 Seconds: 9
> contract address: 0x168A7247B58786edd259502948f5Bf9449C863AD
> block number: 13447029
> block timestamp: 1568294312
> account: 0x29920e756f41F8e691aE0b12D417C19204371E91
> balance: 2.993465175
> gas used: 261393
> gas price: 25 gwei
> value sent: 0 ETH
> total cost: 0.006534825 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.006534825 ETH
2_deploy_contracts.js
=====================
Deploying 'MyContract'
----------------------
> transaction hash: 0xc1f7ec8fee1a23e3d08d0c9e9d6e15fef24feb8ba163e0071dccb1bb90cc0eca
> Blocks: 0 Seconds: 0
> contract address: 0x4D3CFaF8457CEA76c0409f989f9870115B4d2d82
> block number: 13447036
> block timestamp: 1568294340
> account: 0x29920e756f41F8e691aE0b12D417C19204371E91
> balance: 2.9850534
> gas used: 294448
> gas price: 25 gwei
> value sent: 0 ETH
> total cost: 0.0073612 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.0073612 ETH
Summary
=======
> Total deployments: 2
> final cost: 0.013896025 ETH
Summary
=======
> Total deployments: 2
> final cost: 0.013896025 ETH
$ truffle console--network kovan
truffle(kovan)> MyContract.deployed().then((c) => { contract = c })
truffle(kovan)> contract.get()
'myValue'
truffle(kovan)> contract.set("hello world")
{ tx:
'0x7bf63444f3a7bd70e981a7bd49228b1cf1a8c3754daf64c4c7765b8eee46bf37',
receipt:
{ blockHash:
'0xe03d0f43d85f4e41c18a90aa563ebda08899c6b9c38d0cd7779937046e2aed0c',
blockNumber: 13447763,
contractAddress: null,
cumulativeGasUsed: 33629,
from: '0x29920e756f41f8e691ae0b12d417c19204371e91',
gasUsed: 33629,
logs: [],
logsBloom:
'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
root: null,
status: true,
to: '0x4d3cfaf8457cea76c0409f989f9870115b4d2d82',
transactionHash:
'0x7bf63444f3a7bd70e981a7bd49228b1cf1a8c3754daf64c4c7765b8eee46bf37',
transactionIndex: 0,
rawLogs: [] },
logs: [] }
truffle(kovan)> contract.get()
'hello world'