// SPDX-License-Identifier: MIT pragma solidity ^0.6.12; pragma experimental ABIEncoderV2; contract Permit { function getPermitMessage( string memory tokenName, address tokenAddress, string memory version, address owner, address spender, uint256 chainId, uint256 nonce, uint256 amount, uint256 deadline ) public pure returns (bytes32) { bytes32 permitTypehash = keccak256( "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)" ); uint16 permitFuncSelector = uint16(0x1901); bytes32 domain = keccak256( abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(tokenName)), keccak256(bytes(version)), chainId, tokenAddress ) ); return keccak256( abi.encodePacked( permitFuncSelector, domain, keccak256(abi.encode(permitTypehash, owner, spender, amount, nonce, deadline)) ) ); } }