Skip to content

Instantly share code, notes, and snippets.

View TuDo1403's full-sized avatar
👻
Working from home

tu-do.ron TuDo1403

👻
Working from home
  • Ho Chi Minh City - VietNam
  • 06:39 (UTC +07:00)
  • X @TuDo1403
View GitHub Profile
@TuDo1403
TuDo1403 / helpers.ts
Created May 23, 2023 08:24 — forked from hmmdeif/helpers.ts
Hardhat calculate bytes4 interface
// Import contract factory generated from `hardhat compile` with typechain
import { IERC165__factory, IERC2981__factory } from '@custom-types/contracts'
import { ethers } from 'hardhat'
import { utils } from 'ethers'
const getInterfaceID = (contractInterface: utils.Interface) => {
let interfaceID = ethers.constants.Zero;
const functions: string[] = Object.keys(contractInterface.functions);
for (let i = 0; i < functions.length; i++) {
@TuDo1403
TuDo1403 / _eip712_encoding.sol
Created July 15, 2022 08:17 — forked from sambacha/_eip712_encoding.sol
EIP-712 v4 Encoding
// EIP-712 v4 Encoding Arrays
function hash(string[] calldata array) internal pure returns (bytes32 result) {
bytes32[] memory _array = new bytes32[](array.length);
for (uint256 i = 0; i < array.length; ++i) {
_array[i] = keccak256(bytes(array[i]));
}
result = keccak256(abi.encodePacked(_array));
}