D/Labs Docs

ERC-5851 Reciver

Allowing an account or a contract to choose wether they accept a certificate or not.

Accepting to receive certificates

The shortcoming of the base ERC-5851 implementation is whether to accept/reject the issued certificate by any issuing entity. this creates potential sybil attacks with any issuer attributing false identities without allowing the actual owner the choice.
With the ERC5851Receiver contract, an account or a contract must accept to receive certificate before the certificate can be issued to them. The ERC5851Receiver contract must inherit the basic ERC5851 and define a mapping that whitelists addresses that accept to be certified through the IERC-5851 standard. It must also override the certify function defined in the basic contract to allow the implementation of the logic preventing to certify an address that does not approve to be certified through the standard.
pragma solidity ^0.8.0;
import "./ERC5851Issuer.sol";
import "./interfaces/IERC5851Receiver.sol";
contract ERC5851Receiver is ERC5851Issuer, IERC5851Receiver {
mapping(address => bool) private _acceptCertificate;
event Accepted(address claimer, uint256 SBTID);
function certify(address _claimer, uint256 _SBTID) public override(ERC5851Issuer, IERC5851) returns(bool) {
require(_claimer != address(0), "ERC5851Receiver: cannot certify the zero address");
require(_acceptCertificate[_claimer], "ERC5851Receiver: this address doesn't accept this certificate");
// this function also checks if the caller is the admin (issuer)
setVerified(msg.sender, _claimer, _SBTID);
emit Certified(_claimer, _SBTID);
return true;
function acceptCertificate(uint256 _SBTID) external {
emit Accepted(msg.sender, _SBTID);
_acceptCertificate[msg.sender] = true;
The acceptCertificate function allows an account or a contract to register as an address that accepts to be certified. With the ERC5851Receiver contract, any address must register first before they can be certified.