Smart Contract

Overview

All Attestation contracts must inherit the Attestation base contract.

The base contract is ERC721 compliant, which defines the data structure of an Attestation report, and function methods that allow adding and revoking an Attestation.

Once an attestor has successfully submitted an Attestation report, the Attestation contract mints an ERC721 NFT to the attestor's wallet.

Automata 2.0 has currently built various attestation contracts for the various attestation types, namely:

  • SingleStepOptimisticAttestation.sol

  • MultiStepOptimisticAttestation.sol

  • ConsensusBasedAttestation.sol

Full details about the various attestation types can be found in the Attestation section.

Attestation

The Attestation contract itself is considered to be abstract, it is not intended to be deployed as an independent contract. Instead, it is served as a base contract with built-in methods and virtual methods that need to be implemented in the derived contract.

The Attestation Report object structures are defined here.

SingleStepOptimisticAttestation

Introduction of the SingleStepOptimisticAttestation.

If you're looking to build upon the SingleStepOptimisticAttestation, there are 3 pivotal methods awaiting your implementation:

  1. _needVerify - To decide whether the attestation should be verified instantly.

function _needVerify() internal pure returns (bool)
  1. _verify - To validate the correctness and authenticity of the submitted attestation.

function _verify(bytes calldata data) 
    internal view returns (bool verified, bytes memory dataHash)
  1. _generateSVG - To produce a visual representation (SVG image) for the corresponding NFT.

function _generateSVG(uint256 tokenId) internal view returns (string memory)

MultiStepOptimisticAttestation

Introduction of the MultiStepOptimisticAttestation.

If you're looking to build upon the MultiStepOptimisticAttestation, there are 5 pivotal methods awaiting your implementation:

  1. _startChallenge - To handle the logic of starting a challenge.

function _startChallenge(bytes32 hash) internal virtual
  1. _handleEvidence - The challenger and the defender post their evidence on-chain.

function _handleEvidence(bytes32 hash, bytes memory data) internal virtual
  1. _resolveChallenge - To judge the winner of this challenge.

function _resolveChallenge(bytes32 hash) internal virtual returns (bool challengeSuccess)
  1. _cancelChallenge - To handle the logic of cancelling a challenge.

function _cancelChallenge(bytes32 hash) internal virtual
  1. _generateSVG - To produce a visual representation (SVG image) for the corresponding NFT.

function _generateSVG(uint256 tokenId) internal view returns (string memory)

ConsensusBasedAttestation

Introduction of the ConsensusBasedAttestation.

If you're looking to build upon the ConsensusBasedAttestation, there are 3 pivotal methods awaiting your implementation:

  1. _verifyAndUpdateChallenge - To verify whether the signature is valid and from your off-chain consensus party.

function _verifyAndUpdateSignature(
        bytes32 hash, 
        bool agree, 
        bytes calldata signatures
) internal virtual returns (bool valid)
  1. _judgeAttestationStatus - To judge the attestation status according to your consensus mechanism.

function _judgeAttestataionStatus(bytes32 hash) 
    internal virtual returns (AttestationStatus status)
  1. _generateSVG - To produce a visual representation (SVG image) for the corresponding NFT.

function _generateSVG(uint256 tokenId) internal view returns (string memory)

Last updated