etherlime-3-Etherlime Library API-Deployed Contract Wrapper
Posted 慢行厚积
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了etherlime-3-Etherlime Library API-Deployed Contract Wrapper相关的知识,希望对你有一定的参考价值。
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‘);
以上是关于etherlime-3-Etherlime Library API-Deployed Contract Wrapper的主要内容,如果未能解决你的问题,请参考以下文章