Code to reproduce
Iβm using 2 upgradeable contracts: one ERC20 token and another which injects an IERC20Upgradeable
value in its initialiser:
function initialize(IERC20Upgradeable _token) public initializer {
__Pausable_init();
__AccessControl_init();
__UUPSUpgradeable_init();
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(PAUSER_ROLE, msg.sender);
_grantRole(DISBURSER_ROLE, msg.sender);
_grantRole(UPGRADER_ROLE, msg.sender);
token = _token;
}
My current deploy.ts
main()
:
const BanzanToken = await ethers.getContractFactory("BanzanToken");
const banzanToken = await upgrades.deployProxy(BanzanToken);
await banzanToken.deployed();
console.log(`BanzanToken deployed to: ${banzanToken.address}`);
const RewardClaim = await ethers.getContractFactory("RewardClaim");
const rewardClaim = await upgrades.deployProxy(RewardClaim, [banzanToken]);
await rewardClaim.deployed();
console.log(`BanzanToken deployed to: ${rewardClaim.address}`);
Is this the correct way or should I change it?
Also, if I wish to split the deployment, whatβs the equivalent for <Contract>.attach
for upgradeable contracts?
This would also be handy for testing.
Environment
Hardhat 2.8.3