2.3验证部署
现在打开控制台,与kovan测试网络上的智能合约进行交互:
$ 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'
可以看到智能合约已经成功部署 。
3.脚本
包含一个脚本运行器,可对以太坊网络执行自定义脚本 。
让我们创建一个脚本并执行 。
在项目根目录下,创建.js文件,内容如下:
module.exports = function(callback) {web3.eth.getBlock('latest').then(console.log)}
该脚本将从Kovan测试网络获取最新区块的信息 。
执行脚本:
truffle exec script.js --network kovan
输出:
{ author: '0x596e8221a30bfe6e7eff67fee664a01c73ba3c56',difficulty: '340282366920938463463374607431768211454',extraData:'0xde830205058f5061726974792d457468657265756d86312e33362e30826c69',gasLimit: '0x7a1200',gasUsed: '0x5e61',hash:'0x225a1e0b13fd20396af60d049ce9bb94c2f3f7df06c7db260880b62c91997004',logsBloom:'0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',miner: '0x596e8221A30bFe6e7eFF67Fee664A01C73BA3C56',number: 13448162,parentHash:'0x28d00fd7b66771130ed98de5073c7797ee293e7bee4b546793a4b79171555066',receiptsRoot:'0x44617b5733ee59bde159af08ffd6edae36e0964f1724c333f3d1bef0808dee15',sealFields:[ '0x84175e95d7','0xb8412ed900e67f4a72925fb3b495efb3f547411f40d26e972cc0e8b2cf26e40cf84a545e0328199d4880b79c62670129a7db12ac58234bee0866c6376b46ab99e8a200' ],sha3Uncles:'0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',signature:'2ed900e67f4a72925fb3b495efb3f547411f40d26e972cc0e8b2cf26e40cf84a545e0328199d4880b79c62670129a7db12ac58234bee0866c6376b46ab99e8a200',size: 797,stateRoot:'0xe1bbaacfb950361bec70f4ad53a2605e1ac1d2ff0bfd913fe063dc6c5f3252a0',step: '392074711',timestamp: 1568298844,totalDifficulty: '4525729278306228651801195598997744985609807728',transactions:[ '0xf1ae41eac6b32419bc62a6cde9cab4b4ca244899a3d49b4a2461bcf94f504176' ],transactionsRoot:'0xf08c8097ea946f84ce9594ce73648fc0f9f683adef105a5db00c5f1f15e61c2c',uncles: [] }
- 深度|地尔健康为何登榜“2023智能卫浴十大品牌”? 世界智能马桶十大名牌
- 数智驱动,场景赋能:松鼠Ai发布四款人工智能教育硬件标杆产品 松鼠世界之最
- 【Paper】2022_切换拓扑下动态事件触发多智能体系统固定时间一致性
- FF回应贾跃亭欲撕毁合约:恒大阻止其他来源融资 还扣留资金
- 智能锁品牌十大排行榜丨中国-微盾科技指静脉智能门锁 中国智能门锁品牌十大排名榜
- 24小时智能微型图书馆rfid图书自助借还系统
- 招聘 | 国家电网-北京-2024电力设备认知智能技术研发实习生
- 继鹏城之后再攻蓉城,华为智能体如何高起步?
- 智慧养老之养老院解决方案,更加智能化的养老院解决方案-新导智能
- 凯迪仕、德施曼、华为斗法,智能门锁勇闯安全关 世界锁具十大名牌