Truffle 部署合约 truffle migrate

avatar
avatar
云惠网小编
2077
文章
0
评论
2020年10月17日08:43:47 评论 6 次浏览 1987字阅读6分37秒
摘要

Migrations 直译”迁移“

部署合约 truffle migrate

Migrations 直译”迁移“

要运行部署,请运行以下命令

truffle migrate
脚本文件

一个简单的迁移文件,如文件名:4_example_migration.js

文件名以数字为前缀,后缀为描述

var MyContract = artifacts.require("XlbContract");

module.exports = function(deployer) {
  // 部署步骤
  deployer.deploy(MyContract);
};

E:workspaceKnowledgeManagementBlockChainSoliditystudytruffle>truffle migrate

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



Starting migrations...
======================
> Network name:    'development'      #需要在truffle-config.js中配置需要连接的链
> Network id:      1600237726213
> Block gas limit: 6721975 (0x6691b7)


1_initial_migration.js
======================

   Deploying 'AddressBalance'
   --------------------------
   > transaction hash:    0x9d7225302d583d2188a7108256de245d7a5096ea1fbd38f906e676896d53a3a8
部署到指定的网络

truffle migrate --network ropsten

部署到测试网络,网络比较慢,可能会出现timeout

E:workspaceKnowledgeManagementBlockChainSoliditystudytruffle>truffle migrate --network ropsten --reset

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



Starting migrations...
======================
> Network name:    'ropsten'
> Network id:      3
> Block gas limit: 8000000 (0x7a1200)


1_initial_migration.js
======================

   Replacing 'AddressBalance'
   --------------------------
   > transaction hash:    0x4b5f989eceb43c19c954bbe31132a04ea1f29c01033086d1908d0e2e7f316f36
   > Blocks: 2            Seconds: 9
   > contract address:    0xbf6AF9B523807E4f7f4831cCF1541cCfAa0830B2
   > block number:        8849250
   > block timestamp:     1602313584
   > account:             0x3946750f99720c8A497b8be804385fB5b9b83820
   > balance:             104.935565653509715
   > gas used:            172183 (0x2a097)
   > gas price:           20 gwei
   > value sent:          0 ETH
   > total cost:          0.00344366 ETH

   Pausing for 2 confirmations...
   ------------------------------
   > confirmation number: 1 (block: 8849251)
   > confirmation number: 2 (block: 8849252)
   > Saving artifacts
   -------------------------------------
   > Total cost:          0.00344366 ETH


Summary
=======
> Total deployments:   1
> Final cost:          0.00344366 ETH



E:workspaceKnowledgeManagementBlockChainSoliditystudytruffle>

部署成功之后就可以查到对于的合约
https://ropsten.etherscan.io/address/0xbf6AF9B523807E4f7f4831cCF1541cCfAa0830B2

腾讯云618
avatar
2020年10月份自考总结 阿里云开发与运维

2020年10月份自考总结

  这次自考考了3科分别是英语,数据结构,C++。通过这段时间的学习,过不过的吧,尽力了。尽人事,听天命。过不了,下次继续努力,放平心态。分别说一下这三科的学习。
腾讯云618
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: