Dear blockchain developers, I have a ERC20 with restriction of minting only on Polygon chain:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.23;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyPolygonToken is ERC20 {
uint256 public constant MINT_CHAIN_ID = 137;
error ZeroAddress();
constructor(
string memory _name,
string memory _symbol,
) ERC20(_name, _symbol) {
if (getChainId() == MINT_CHAIN_ID) {
_mint(msg.sender, 1_000_000 ether);
}
}
function getChainId() public view returns (uint256) {
uint256 chainId;
assembly {
chainId := chainid()
}
return chainId;
}
}
I want to create unit test to test the correct execution, but have problem. I tried to create second local network with id "137" by fork Polygon network, but I can't get the signers of the chain. Do you have any idea how I can easily do it, or maybe some extension for hardhat which can help me?
Thanks in advance.