5. Attest

Construct an attestation object

import { genRandomSalt, hashOne } from '@unirep/crypto'
import { Attestation } from '@unirep/contracts' 

const attesterID = await contract.attesters(attester.address)
// positive reputation
const posRep = 10
// negative reputation
const negRep = 3
// a random bigint
const graffitiPreImage = genRandomSalt()
// hash of the random bigint
const graffiti = hashOne(graffitiPreImage)
// a sign up flag in the attester's application
const signUp = 0

// the attestation object
const attestation = new Attestation(
    attesterID,
    posRep,
    negRep,
    graffiti,
    signUp
)

Submit the attestation with epoch key proof index

const fromProofIdx = 0 // if the attestation is not from a spending reputation action
const config = await contract.config()
const tx = await contract
    .connect(attester)
    .submitAttestation(
        attestation,
        proof.epochKey,
        proofIdx,
        fromProofIdx,
        {
            value: config.attestingFee
        }
    )

Attesting fee can be set in UniRep configuration to force attesters attest an epoch key with an amount of ETH .

Last updated