ethers/lib/utils#toUtf8Bytes TypeScript Examples

The following examples show how to use ethers/lib/utils#toUtf8Bytes. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: signatures.ts    From ERC20Permit with GNU General Public License v3.0 6 votes vote down vote up
// Gets the EIP712 domain separator
export function getDomainSeparator(name: string, contractAddress: string, chainId: number) {
  return keccak256(
    defaultAbiCoder.encode(
      ['bytes32', 'bytes32', 'bytes32', 'uint256', 'address'],
      [
        keccak256(toUtf8Bytes('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')),
        keccak256(toUtf8Bytes(name)),
        keccak256(toUtf8Bytes('1')),
        chainId,
        contractAddress,
      ]
    )
  )
}
Example #2
Source File: sign-utils.ts    From shoyu with MIT License 6 votes vote down vote up
convertToHash = (text: string) => {
    return keccak256(toUtf8Bytes(text));
}
Example #3
Source File: signatures.ts    From ERC20Permit with GNU General Public License v3.0 5 votes vote down vote up
PERMIT_TYPEHASH = keccak256(
  toUtf8Bytes('Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)')
)