// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "hardhat/console.sol";
contract MyToken is
Initializable,
ERC1155Upgradeable,
OwnableUpgradeable,
PausableUpgradeable,
ERC1155BurnableUpgradeable,
UUPSUpgradeable
{
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
string public _typeOfSC;
string public _role;
function initialize(string memory typeOfSC_, string memory role_)
public
initializer
{
console.log("log 1");
__ERC1155_init("");
__Ownable_init();
__Pausable_init();
__ERC1155Burnable_init();
__UUPSUpgradeable_init();
_typeOfSC = typeOfSC_;
console.log("_typeOfSC : ");
console.log(_typeOfSC);
console.log("typeOfSC_ : ");
console.log(typeOfSC_);
_role = role_;
setType(typeOfSC_);
}
function setType(string memory newuri) public {
_typeOfSC = newuri;
}
function typeOfSC() public view virtual returns (string memory) {
console.log("_typeOfSC");
console.log(_typeOfSC);
return _typeOfSC;
}
function role() public view virtual returns (string memory) {
return _role;
}
function setURI(string memory newuri) public onlyOwner {
_setURI(newuri);
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function mint(
address account,
uint256 id,
uint256 amount,
bytes memory data
) public onlyOwner {
_mint(account, id, amount, data);
}
function mintBatch(
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) public onlyOwner {
_mintBatch(to, ids, amounts, data);
}
function _beforeTokenTransfer(
address operator,
address from,
address to,
uint256[] memory ids,
uint256[] memory amounts,
bytes memory data
) internal override whenNotPaused {
super._beforeTokenTransfer(operator, from, to, ids, amounts, data);
}
function _authorizeUpgrade(address newImplementation)
internal
override
onlyOwner
{}
}
Using this smart contract I want to initialize two state variable, but when I try to get this two variable after smart contract deployment, their value is empty.