👨‍💻How to use the libraries


List of deployed Registries per network can be found here.


npm i @zero-labs/smart-contracts


import { CertificateContracts } from '@zero-labs/smart-contracts';


const provider = new providers.JsonRpcProvider('https://volta-rpc.energyweb.org'); // Replace with your RPC node of choice
const signer = new Wallet('0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1', provider); // Replace with your private key for deployment

const certificateContracts = new CertificateContracts(signer);
await certificateContracts.deploy(
    1 // (OPTIONAL): Replace with your desired topic of choice, otherwise the next available topic will be assigned to you

const {
    registry, // Registry smart contract
    batches, // Batches smart contract
    topic // Topic under which the certificates would be minted
} = certificateContracts;    


Creating an empty batch

await batches.createBatches(1);

Setting an redemption statement for a batch

await batches.setRedemptionStatement(

Minting tokens

import { encodeMetadata } from '@zero-labs/smart-contracts';
import { BigNumber } from 'ethers';
import { DateTime } from 'luxon';

await batches.mint(
    '1', // Batch ID
    ['0xd46aC0Bc23dB5e8AfDAAB9Ad35E9A3bA05E092E8'], // Mint TO
    [1e6], // Amount
        generator: {
            id: "123",
            name: "Ime",
            energySource: "SOLAR",
            region: "EU",
            country: "HR",
            capacity: BigNumber.from(1e9),
            commissioningDate: BigNumber.from(
        generationStartTime: BigNumber.from(
        generationEndTime: BigNumber.from(DateTime.fromISO("2022-01-31").valueOf()),
        productType: "I-REC",
        data: '',

Transferring the tokens

import { utils } from 'ethers';

await registry.safeTransferFrom(
    '0xD173313A51f8fc37BcF67569b463abd89d81844f', // FROM
    '0xd46aC0Bc23dB5e8AfDAAB9Ad35E9A3bA05E092E8', // TO
    '1', // CERTIFICATE ID
    1e6, // AMOUNT
    utils.solidityPack(['uint256'], [TransactionType.TRANSFER]), // Needed as metadata to differentiate the call as a transfer

Claiming the tokens

import { encodeClaimData } from '@zero-labs/smart-contracts';

await registry.safeTransferAndClaimFrom(
    '0xD173313A51f8fc37BcF67569b463abd89d81844f', // FROM
    '0xd46aC0Bc23dB5e8AfDAAB9Ad35E9A3bA05E092E8', // TO
    '1', // CERTIFICATE ID
    1e6, // AMOUNT
    '', // Additional claiming metadata, unused for now
        beneficiary: "Test beneficiary",
        region: "string",
        countryCode: "string",
        periodStartDate: "string",
        periodEndDate: "string",
        purpose: "string",
        consumptionEntityID: "string",
        proofID: "string",

Last updated