Inherits: Initializable, ERC721Upgradeable, ERC721BurnableUpgradeable, EIP712Upgradeable, AccessManagedUpgradeable, UUPSUpgradeable, WitnessConsumer

Author: Ernesto García

A contract to track digital endorsements according to Mexican comercial and debt instruments law. This contract allows for any user to mint a new token by providing the hash of the digital document a provenance proof checked against the Witness and a valid signature from an authorizer. Privacy is ensured by only tracking the hash of the document, and not the document itself.

Property is tied to regular Ethereum addresses. It’s the responsibility of the developer to implement a robust regulatory framework to ensure the link between the owner and such address.

security-contact: security@plumaa.id

State Variables

ENDORSER_STORAGE

bytes32 private constant ENDORSER_STORAGE = 0xd4afa66895d5fdd6c8f53a8b47d14ebe8786dd18400174140b53bbb9a8838e00;

PROVENANCE_AUTHORIZER_ROLE

uint64 internal constant PROVENANCE_AUTHORIZER_ROLE = uint64(bytes8(keccak256("PlumaaID.PROVENANCE_AUTHORIZER")));

_MINT_AUTHORIZATION_TYPEHASH

bytes32 internal constant _MINT_AUTHORIZATION_TYPEHASH = keccak256("MintRequest(bytes32 leaf,address to)");

Functions

constructor

Note: oz-upgrades-unsafe-allow: constructor

constructor();

getProvenanceHash

Leaf hash. Uses SHA256 according to the algorithms approved by the Mexican government.

function getProvenanceHash(bytes memory data) public pure virtual override returns (bytes32);

initialize

Initializes the contract setting an initial authority and a Witness contract

function initialize(address initialAuthority, IWitness witness) public initializer;

WITNESS

The Witness contract that this contract uses to verify provenance.

function WITNESS() public view virtual override returns (IWitness);

mint

Mints a new token for the provided to address if the proof is valid and nullifies it so it can’t be used again.

function mint(MintRequestData calldata request, Proof calldata proof) external;

setWitness

Sets the Witness contract

Witness is set by default to the mainnet address, it should be updated to the correct address before deployment when deploying to testnets.

function setWitness(IWitness witness) external restricted;

_baseURI

function _baseURI() internal pure override returns (string memory);

_validateAndNullifyProof

Checks whether a proof is valid and nullifies it so it can’t be used again.

Requirements:

  • The leaf was not nullified before.
  • The mint request was signed by an authorizer.
  • The authorizer is a member of the PROVENANCE_AUTHORIZER_ROLE.
  • The proof is valid according to the Witness contract.
function _validateAndNullifyProof(MintRequestData calldata request, Proof calldata proof) internal;

_getEndorserStorage

Get EIP-7201 storage

function _getEndorserStorage() private pure returns (EndorserStorage storage $);

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal override restricted;

Errors

AlreadyClaimed

error AlreadyClaimed();

InvalidAuthorization

error InvalidAuthorization();

Structs

MintRequestData

struct MintRequestData {
    address authorizer;
    address to;
    bytes signature;
}

EndorserStorage

struct EndorserStorage {
    BitMaps.BitMap _nullifier;
    IWitness _witness;
}