Skip to content

Latest commit

 

History

History
85 lines (59 loc) · 5.88 KB

File metadata and controls

85 lines (59 loc) · 5.88 KB

Create an Attestation

After determining the Schema and potential Modules to use, and after the deployment and registration of your Portal, you can begin creating Attestations.

Attestation registration

Attestation registration at the Portal level takes 2 parameters, defined as follows:

PropertyDescription
attestationPayloadThe payload to attest
validationPayloadThe payloads to validate via the modules to issue the attestation

attestationPayload is defined in Solidity as follows:

struct AttestationPayload {
  bytes32 schemaId;
  uint64 expirationDate;
  bytes subject;
  bytes attestationData;
}
PropertyDescription
schemaIdThe identifier of the schema this attestation adheres to
expirationDateThe expiration date of the attestation
subjectThe ID of the attestee, EVM address, DID, URL etc
attestationDataThe attestation data

Manually registering an Attestation in the AttestationRegistry contract

To register an Attestation into the AttestationRegistry contract, you need to go through the Portal you have previously deployed an registered, using the attest function:

function attest(
  AttestationPayload memory attestationPayload,
  bytes[] memory validationPayload
) public payable;

When attesting, the registry performs a set of integrity checks on the new attestation:

  • verifies the schemaId exists
  • verifies the subject field is not blank
  • verifies the attestationData field is not blank

Using a blockchain explorer

Instead of drafting the smart contract call by hand, you can benefit from a chain explorer interface. Let's use the Linea Sepolia explorer, Lineascan.

The form generated by Lineascan to interact with the Portal contract

  1. Retrieve the address of the Portal contract you previously deployed
  2. Access the Portal contract on Lineascan
  3. Got to the "Contract" tab
  4. Got to the "Write" tab
  5. Connect your wallet and fill the attest form with the parameters described above
  6. Send the transaction

Using the official Verax SDK

We have seen rather manual ways to create an Attestation, now let's focus on the easiest way: via the Verax SDK.

{% hint style="info" %} Check this page to discover how to instantiate ethe Verax SDK. {% endhint %}

Once you have an SDK instance, you can create an Attestation like this:

await veraxSdk.portal.attest(
        "0x2fafe2c217be096e09b64c49825fe46b7c3e33b2",
        {
                schemaId: "0x9ba590dd7fbd5bd1a7d06cdcb4744e20a49b3520560575cd63de17734a408738",
                expirationDate: 1693583329,
                subject: "0x828c9f04D1a07E3b0aBE12A9F8238a3Ff7E57b47",
                attestationData: [{ isBuidler: true }],
        },
        []
);

Attestation Metadata

When creating an attestation, you simply need to specify four properties, as outlined above, however, the attestation registry itself automatically populates the other fields in the attestation metadata at the point at which it is created. The full list of attestation metadata is included below:

PropertyDatatypeDescription
attestationIdbytes32The unique identifier of the attestation
schemaIdbytes32The identifier of the schema this attestation adheres to
replacedByuint256The attestation ID that replaces this attestation
attesteraddressThe address issuing the attestation to the subject
portaladdressThe address of the portal that created the attestation
attestedDateuint64The date the attestation is issued
expirationDateuint64The expiration date of the attestation
revocationDateuint64The date when the attestation was revoked
versionuint16Version of the registry when the attestation was created
revokedboolWhether the attestation is revoked or not
revocationDateuint64If revoked, the date it was revoked / replaced
subjectbytesThe ID of the attestee e.g. an EVM address, DID, URL etc.
attestationDatabytesThe raw attestation data

The attestationId is derived from an internal auto-incremented counter, converted from uint32 to byte32. This corresponds to the total attestations issued. Moreover, the ID is prefixed with a chain identifier. This way, an attestation issued on Arbitrum cannot have t he same ID as an attestation issued on Linea, which is great in terms of cross-chain discovery!

Once the attestation is successfully created in the registry, an AttestationRegistered event is emitted with the attestation ID, and subsequently picked up by indexers.