Verified contractPartialUNLICENSED
HumanCheck
Address0xcf210904cd132ccddc563c3cd3aed1c312bae900
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.38
- Same code
Only this contract
Details
- Compiler
- solc 0.8.38+commit.1835d247
- Language
- solidity
- Optimization
- Yes, 1,000,000 runs
- EVM version
- cancun
- License
- UNLICENSED
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,502,112
- Creation transaction
- 0x6b4b459f70…5bfde674b6
2 files
- src/helpers/HumanCheck.solmain3.18 KB
- src/interfaces/IHuman.sol241 B
src/helpers/HumanCheck.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.38;
import {IHuman} from "../interfaces/IHuman.sol";
/// @title HumanCheck
/// @notice Answers "is this address a verified human" from two sources, either one enough:
/// - World's Address Book (World Chain only): `addressVerifiedUntil(account)` later than now;
/// - the Access0x1 human badge (CredentialSbt, every chain): `hasValidCredential(account, credType)`,
/// a badge minted once per World ID per chain, valid 365 days, revocable.
/// A source that is not set, reverts, runs out of its gas or answers in a shape it should not counts as "no".
/// @dev Nothing here is owned or can change: a new source means a new HumanCheck, named once by the pot's Safe.
contract HumanCheck is IHuman {
/// @notice The most gas one source may use for one answer.
uint256 public constant SOURCE_GAS = 40_000;
/// @notice World's Address Book, or zero where it does not exist (every chain but World Chain).
address public immutable addressBook;
/// @notice The badge contract (CredentialSbt), or zero.
address public immutable badges;
/// @notice The badge type that counts: keccak256("access0x1.human").
bytes32 public immutable credType;
error NoSource();
error NoCode();
constructor(address addressBook_, address badges_, bytes32 credType_) {
if (addressBook_ == address(0) && badges_ == address(0)) revert NoSource();
if (addressBook_ != address(0) && addressBook_.code.length == 0) revert NoCode();
if (badges_ != address(0) && (badges_.code.length == 0 || credType_ == bytes32(0))) revert NoCode();
addressBook = addressBook_;
badges = badges_;
credType = credType_;
}
/// @inheritdoc IHuman
function isHuman(address account) external view returns (bool) {
return _inAddressBook(account) || _holdsBadge(account);
}
function _inAddressBook(address account) private view returns (bool) {
if (addressBook == address(0)) return false;
(bool ok, uint256 until) = _read(addressBook, abi.encodeWithSignature("addressVerifiedUntil(address)", account));
return ok && until > block.timestamp;
}
function _holdsBadge(address account) private view returns (bool) {
if (badges == address(0)) return false;
(bool ok, uint256 word) =
_read(badges, abi.encodeWithSignature("hasValidCredential(address,bytes32)", account, credType));
return ok && word == 1;
}
/// @dev One word back, or not ok. The answer is copied only when it is exactly 32 bytes, so a source cannot
/// make the caller pay for a large return.
function _read(address source, bytes memory input) private view returns (bool ok, uint256 word) {
uint256 gasCap = SOURCE_GAS;
assembly ("memory-safe") {
ok := staticcall(gasCap, source, add(input, 0x20), mload(input), 0, 0)
if ok {
ok := eq(returndatasize(), 0x20)
if ok {
returndatacopy(0, 0, 0x20)
word := mload(0)
}
}
}
}
}
src/interfaces/IHuman.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.38;
/// @title IHuman
/// @notice One question: is this address a verified human right now.
interface IHuman {
function isHuman(address account) external view returns (bool);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "none",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 1000000,
"enabled": true
},
"viaSSACFG": false,
"evmVersion": "cancun",
"remappings": [
"forge-std/=lib/forge-std/src/",
"hookmate/=lib/hookmate/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@uniswap/v4-core/=lib/uniswap-hooks/lib/v4-core/",
"@uniswap/v4-periphery/=lib/uniswap-hooks/lib/v4-periphery/",
"solmate/=lib/uniswap-hooks/lib/v4-core/lib/solmate/",
"@chainlink/contracts-ccip/contracts/=lib/chainlink-ccip/chains/evm/contracts/",
"@chainlink/contracts/=lib/chainlink-evm/contracts/",
"@openzeppelin/[email protected]/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/[email protected]/=lib/openzeppelin-contracts/contracts/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"lib/uniswap-hooks/lib/v4-core/lib/solmate/:ds-test/=lib/uniswap-hooks/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-core/lib/solmate/:ds-test/=lib/uniswap-hooks/lib/v4-core/lib/solmate/lib/ds-test/src/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/uniswap-hooks/lib/v4-periphery/lib/permit2/:openzeppelin-contracts/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/openzeppelin-contracts/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/:openzeppelin-contracts/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
"lib/uniswap-hooks/lib/v4-core/:openzeppelin-contracts/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/",
"lib/uniswap-hooks/lib/v4-core/:openzeppelin-contracts/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/",
"lib/uniswap-hooks/lib/v4-periphery/:v4-core/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/src/",
"lib/uniswap-hooks/lib/v4-periphery/:v4-core/=lib/uniswap-hooks/lib/v4-periphery/lib/v4-core/src/",
"lib/uniswap-hooks/:v4-core/=lib/uniswap-hooks/lib/v4-core/src/",
"lib/uniswap-hooks/:v4-core/=lib/uniswap-hooks/lib/v4-core/src/",
"@ensdomains/=lib/uniswap-hooks/lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/",
"chainlink-ccip/=lib/chainlink-ccip/",
"chainlink-evm/=lib/chainlink-evm/contracts/",
"ds-test/=lib/uniswap-hooks/lib/v4-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/uniswap-hooks/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
"hardhat/=lib/uniswap-hooks/lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"permit2/=lib/uniswap-hooks/lib/v4-periphery/lib/permit2/",
"uniswap-hooks/=lib/uniswap-hooks/src/",
"v4-core/=lib/uniswap-hooks/lib/v4-core/src/",
"v4-periphery/=lib/uniswap-hooks/lib/v4-periphery/"
],
"experimental": false
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.