// `public` means that the collection is public, anyone can view and read
// the records in the collection. You can still implement rules on who can
// edit the data by defining functions on the collection.
@public
collection VerifiableCredentialMetadata {
// `id` is unique and required on all collections
id: string;
// Use the NFT format
name: string;
// Image could link to the location of the file on IPFS, Arweave, etc.
image: string;
// Any additional properties you want
level: number;
points: number;
constructor (id: string, name: string, image: string) {
this.id = id;
this.name = name;
this.image = image;
this.points = 0;
}
// You can add your own functions to determine rules
// on who can update the data
function setPoints (points: number) {
// Check if the caller is a master address (or null address for immutable metadata).
if (ctx.publicKey != '0x000000000') {
error('You are not allowed to update the points.');
}
this.points = points;
}
}