Data Models¶
Schema¶
struct Schema {
address registrant;
bool revocable;
DataLocation dataLocation;
uint64 maxValidFor;
ISPHook hook;
uint64 timestamp;
string data;
}
registrant: The address that registered this schema.revocable: Whether Attestations that adopt this Schema can be revoked.dataLocation: WhereSchema.datais stored. See DataLocation.maxValidFor: The maximum number of seconds that an Attestation can remain valid. 0 means Attestations can be valid forever. This is enforced throughAttestation.validUntil.hook: TheISPHookthat is called at the end of every function. 0 means no hook is set. See ISPHook.timestamp: When the schema was registered. This is automatically populated by_register(...).data: The raw schema thatAttestation.datashould follow. Since there is no way to enforce this, it is astringfor easy readability.
Notes¶
- Use the ISPHook to take payments.
- Reverting from within the ISPHook reverts the entire transaction, so the hook can add checks to validate attestation creation (for example, a whitelist). Pass additional information to the hook in the
extraDataargument ofattest().
Attestation¶
struct Attestation {
uint64 schemaId;
uint64 linkedAttestationId;
uint64 attestTimestamp;
uint64 revokeTimestamp;
address attester;
uint64 validUntil;
DataLocation dataLocation;
bool revoked;
bytes[] recipients;
bytes data;
}
schemaId: TheSchemathat this Attestation is based on. It must exist.linkedAttestationId: Useful if the current Attestation references a previous Attestation. It can either be 0 or an existing attestation ID.attestTimestamp: When the attestation was made. This is automatically populated by_attest(...).revokeTimestamp: When the attestation was revoked. This is automatically populated by_revoke(...).attester: The attester.validUntil: The expiration timestamp of the Attestation. Must respectSchema.maxValidFor. 0 indicates no expiration date.dataLocation: WhereAttestation.datais stored. See DataLocation.revoked: Whether the Attestation has been revoked. It is possible to make a revoked Attestation.recipients: The intended ABI-encoded recipients of this Attestation. This is of typebytesto support non-EVM recipients.data: The raw data of the Attestation based onSchema.data. This is not enforced. We recommend usingabi.encode.
Notes¶
- By default,
attesteris the caller ofattest(). If the call includes a delegate signature,attesteris instead the address in theAttestationobject passed to the function. recipientsis an array of addresses, so one attestation can have many recipients. If no recipient is provided when an attestation is created, theattesteris used.- By default,
datais not validated when an attestation is created. You can validate it in an ISPHook on the schema. Useabi.encodeandabi.decodeto handle the data, or functions like viem'sencodeAbiParametersanddecodeAbiParametersin the frontend.
OffchainAttestation¶
attester: The attester. At this time, the attester must be the caller ofattestOffchain().timestamp: Theblock.timestampof the function call.
Notes¶
OffchainAttestationis for true off-chain attestations: data is stored on other servers and only a record of the attestation is stored on-chain. This differs from the "Offchain Attestations" made with Sign Protocol's schema and attestation builders, which use schemas and attestations with data stored on Arweave, handled the same way as on-chain data.
DataLocation¶
This enum indicates where Schema.data and Attestation.data are stored.
Notes¶
- A
DataLocationthat is notONCHAINmeans the associated attestation is a Hybrid Attestation. The SDK handles this for you, but if you call the Sign Protocol smart contracts directly, pass the correctdatavalues (encoded CIDs) when creating a hybrid attestation.