How can I fix my code, the chainid is 9999.I tried changing chainId := chainid to chainId := chainid() but it doesn't work. Here is the whole code:
pragma solidity 0.6.12;
import './interfaces/IUniswapV2ERC20.sol';
import 'contracts/libraries/SafeMath.sol';
contract AkalinsToken is IUniswapV2ERC20 {
using SafeMath for uint;
string public name = 'Akalin';
string public constant symbol = 'AKALIN';
uint8 public constant decimals = 18;
address[] private allHolders; // save all the holders (there can be also addresses with 0 balance but every address is included only once
uint public totalSupply;
mapping(address => uint) public balanceOf;
mapping(address => mapping(address => uint)) public allowance;
mapping(address => bool) private isHolder; // to check whether the address has been added to allHolders before
bytes32 public DOMAIN_SEPARATOR;
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
mapping(address => uint) public nonces;
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
event NameChanged(string newName);
constructor() public {
uint chainId;
assembly{
chainId := chainid
}
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)'),
keccak256(bytes(name)),
keccak256(bytes('1')),
chainId,
address(this)
)
);
}
function _mint(address to, uint value) internal {
totalSupply = totalSupply.add(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(address(0), to, value);
if(!isHolder[to]){
allHolders.push(to);
isHolder[to] = true;
}
}
function _burn(address from, uint value) internal {
balanceOf[from] = balanceOf[from].sub(value);
totalSupply = totalSupply.sub(value);
emit Transfer(from, address(0), value);
}
function _approve(address owner, address spender, uint value) private {
allowance[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _transfer(address from, address to, uint value) private {
balanceOf[from] = balanceOf[from].sub(value);
balanceOf[to] = balanceOf[to].add(value);
emit Transfer(from, to, value);
if(!isHolder[to]){
isHolder[to] = true;
allHolders.push(to);
}
}
function approve(address spender, uint value) external returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transfer(address to, uint value) external returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
function transferFrom(address from, address to, uint value) external returns (bool) {
if (allowance[from][msg.sender] != uint(-1)) {
allowance[from][msg.sender] = allowance[from][msg.sender].sub(value);
}
_transfer(from, to, value);
return true;
}
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external {
require(deadline >= block.timestamp, 'UniswapV2: EXPIRED');
bytes32 digest = keccak256(
abi.encodePacked(
'\x19\x01',
DOMAIN_SEPARATOR,
keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
)
);
address recoveredAddress = ecrecover(digest, v, r, s);
require(recoveredAddress != address(0) && recoveredAddress == owner, 'UniswapV2: INVALID_SIGNATURE');
_approve(owner, spender, value);
}
function findLargestHolder() internal view returns (address) {
address largestHolder = address(0);
uint largestBalance = 0;
for (uint i = 0; i < allHolders.length; i++) {
uint balance = balanceOf[allHolders[i]];
if (balance > largestBalance) {
largestBalance = balance;
largestHolder = allHolders[i];
}
}
return largestHolder;
}
modifier onlyLargestHolder() {
require(msg.sender == findLargestHolder(), "Caller is not the largest holder");
_;
}
// The person with the most balance can change the Tokens name
function changeTokenName(string memory newName) public onlyLargestHolder {
name = newName;
emit NameChanged(newName);
}
}