博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
etherlime-3-Etherlime Library API-Deployed Contract Wrapper
阅读量:6147 次
发布时间:2019-06-21

本文共 2296 字,大约阅读时间需要 7 分钟。

Deployed Contract Wrapper部署合约的封装

Wrappers封装

One of the advancements of the etherlime is the result of the deployment - the DeployedContractWrapper

etherlime的进步之一就是部署的结果-DeployedContractWrapper

The DeployedContractWrapper is a powerful object that provides you with ethers.Contract amongst other functionalities. This allows you to start using your deployed contract right away as part of your deployment sequence (f.e. you can call initialization methods)

DeployedContractWrapper是一个能够在其他功能中提供给你 ethers.Contract的强势的对象。这将允许你马上开始使用部署的合约作为部署序列的一部分

In addition it exposes you verboseWaitForTransaction(transaction, transactionLabel) function. This function can be used to wait for transaction to be mined while giving you verbose output of the state. In addition it allows you to specify a label for the transaction you are waiting for, so that you can get a better understanding of what transaction is being waited for. This comes in handy when deployment scripts start to grow.

除了暴露给你verboseWaitForTransaction(transaction, transactionLabel)函数。当给你状态的详细输出时,这个函数可以用来等待交易被挖矿。除此之外还允许你给你等待的交易指定标签,这样你就可以对正在等待的交易有更好的理解。当部署脚本开始增长时,这非常有用。

const contractWrapper = await deployer.deploy(ICOTokenContract);const transferTransaction = await contractWrapper.contract.transferOwnership(randomAddress);const result = await contractWrapper.verboseWaitForTransaction(transferTransaction, 'Transfer Ownership');

 verboseWaitForTransaction函数的作用就是等待交易成功被记录在区块上,然后返回交易的receipt

 

Working with previously deployed contracts使用以前部署的和合约

Sometimes you want to work with already deployed contract. The deployer object allows you to wrap such an deployed contract by it’s address and continue using the power of the wrapper object. The function you can use to achieve this is wrapDeployedContract(contract, contractAddress).

有时你想要使用已经部署的合约。部署对象将允许你通过它的地址来封装这个部署合约,然后就可以继续使用这个封装对象的功能。你可以使用wrapDeployedContract(contract, contractAddress)这个函数来得到封装对象

const deployedContractWrapper = deployer.wrapDeployedContract(SomeContractWithInitMethod, alreadyDeployedContractAddress);const initTransaction = await deployedContractWrapper.contract.init(randomParam, defaultConfigs);const result = await deployedContractWrapper.verboseWaitForTransaction(initTransaction, 'Init Contract');

 

 

转载于:https://www.cnblogs.com/wanghui-garcia/p/10072402.html

你可能感兴趣的文章
百度贴吧爬虫node+vue baidu_tieba_crawler
查看>>
笨方法使用Kubernetes实现持续交付
查看>>
Go 领军人物谢孟军:智能制造渴望银弹,首先要摒弃偏见
查看>>
专访Connolly:为什么我们需要手动回归测试宣言?
查看>>
从AI医疗到量子计算,亚洲研究院如何成为微软发展的生命力?
查看>>
Red Hat与微软合作,将致力于构建企业级Linux版.NET
查看>>
Rust 1.27支持SIMD
查看>>
如何用度量影响敏捷环境
查看>>
未来的C#之覆写放宽
查看>>
GitHub GraphQL API已正式可用
查看>>
GitHub:我们为什么会弃用jQuery?
查看>>
苹果Q1财报出炉:手机收入下滑15%,服务收入增长19%
查看>>
用ASP.NET Core 2.0 建立规范的 REST API -- 预备知识
查看>>
Pandas时间序列
查看>>
开发者论坛一周精粹(第四十八期) ICP经营许可证办理流程
查看>>
基于Go的websocket消息服务
查看>>
流计算独享模式正式邀测
查看>>
hibernate笔记--缓存机制之 二级缓存(sessionFactory)和查询缓存
查看>>
Ceph,TFS,FastDFS,MogileFS,MooseFS,GlusterFS 对比
查看>>
无人机协助科研人员探寻珍稀植物,仅需20分钟
查看>>