Hi.
I have a contract
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./safeMath.sol";
import "./Counters.sol";
import "./IERC20Standard.sol";
import "./GameContract.sol";
contract NFT721Contract is Initializable, ERC721URIStorageUpgradeable, ERC721EnumerableUpgradeable, OwnableUpgradeable {
...
function initialize() public initializer {
OwnableUpgradeable.__Ownable_init();
__ERC721_init("Name", "Symb");
}
...
}
Use deploy
const { ethers, upgrades } = require('hardhat');
async function main() {
const NFT721Contract = await ethers.getContractFactory('NFT721Contract');
console.log('Deploying NFT...');
const nftContract = await upgrades.deployProxy(NFT721Contract, { initializer: 'initialize' });
await nftContract.deployed();
console.log('NFT - deployed to:', nftContract.address);
}
main();
After deployment, I have NFTs available.
But the GameContract was not initialized.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "./safeMath.sol";
import "./IERC20Standard.sol";
import "./NFT721Contract.sol";
contract GameContract is Initializable, OwnableUpgradeable {
...
bool public gameStatus;
function initialize() public initializer {
OwnableUpgradeable.__Ownable_init();
gameStatus = true;
}
...
}
There are other variables in the initialization method and they are left empty after deployment.
Heeelp
I've been trying to tie contracts for 3 days...
Or are they impossible for one proxy address?