import { getUnirepContract } from'@unirep/contracts'// user can connect the Unirep smart contract with getUnirepContractconstcontract=awaitgetUnirepContract(UNIREP_CONTRACT_ADDRESS, signer)
Use the semaphore identity commitment to sign up in UniRep smart contract.
import { ZkIdentity } from'@unirep/crypto'// generate a semaphore identityconstidentity=newZkIdentity()// sign up in UniRep smart contract with semaphore identity commitmentconsttx=awaitcontract.userSignUp(identity.genIdentityCommitment())
Save the serialized semaphore identity.
// print the semaphore identity and save itconsole.log(identity.serializeIdentity())// Example output:// {"identityNullifier":"27d1ae5c98aab64b851a9c668a7eec0d835867a17d4b9454a8bf9824836271d6","identityTrapdoor":"2596ecc2a1e1f6a8f279e097464e6edc3b18b946d934398dfe52a34c4e414e67","secret":["27d1ae5c98aab64b851a9c668a7eec0d835867a17d4b9454a8bf9824836271d6","2596ecc2a1e1f6a8f279e097464e6edc3b18b946d934398dfe52a34c4e414e67"]}