Develop an OnchainVerifiable Contract
isVerified
function isVerified(address addr, DojangAttesterId attesterId) external view returns (bool);Deployed OnchainVerifiable contract
Network
OnchainVerifier contract Address
Verfier ID
Example
Verified ERC20
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
type DojangAttesterId is bytes32;
interface IVerifier {
function isVerified(address primaryAddress, DojangAttesterId attesterId) external view returns (bool);
}
contract VerifiedERC20 is ERC20 {
IVerifier public immutable verifier;
DojangAttesterId public immutable attesterId;
error NotVerified(address addr);
constructor(
string memory name_,
string memory symbol_,
address verifier_,
DojangAttesterId attesterId_,
uint256 initialSupply
) ERC20(name_, symbol_) {
require(verifier_ != address(0), "verifier is zero");
verifier = IVerifier(verifier_);
attesterId = attesterId_;
_mint(msg.sender, initialSupply);
}
// OZ v5: single hook that manages all transactions (mint/burn/transfer)
function _update(address from, address to, uint256 value) internal override {
// Only verifiable for normal transfer (= both sides non-zero)
if (from != address(0) && to != address(0)) {
// Token holder (from) must be verified
if (!verifier.isVerified(from, attesterId)) revert NotVerified(from);
// Optionally verify caller (the spender in transferFrom)
if (!verifier.isVerified(_msgSender(), attesterId)) revert NotVerified(_msgSender());
// Optionally verify recipient (to)
if (!verifier.isVerified(to, attesterId)) revert NotVerified(to);
}
super._update(from, to, value);
}
}
Verified ERC721
Last updated