This smart contract allows the registration of verifiable credential attestations on the NEAR blockchain. It is used as part of a decentralized identity (DID) and verifiable credentials (VC) flow, providing on-chain traceability of the issuer, subject, and the referenced content via a cid.
Registers a credential issued in the contract. Can only be called by the authorized issuer (signer in the app).
-
Parameters:
{ "subject_did": "did:near:usuario.testnet", "cid": "bafybeigdyrzi...", "expires_at": null } -
cid definition: The
cidrepresents the SHA-256 hash (Base64-encoded) of the verifiable credential JSON. It is used as a unique identifier for the credential on-chain. -
Requirements:
- The
cidmust not have been previously issued for thatsubject_did. - The
signerof the transaction will be recorded as the issuer.
- The
-
Recommended Gas:
30 TGas(30000000000000)
Checks if a credential (subject_did, cid) has been issued and has not expired.
-
Parameters:
{ "subject_did": "did:near:usuario.testnet", "cid": "bafybeigdyrzi..." } -
Returns:
true | false
near call neardtiprooftype.testnet issue_credential \
'{"subject_did": "did:near:usuario.testnet", "cid": "bafybeigdyrzi...", "expires_at": null}' \
--accountId issuer.testnet --gas 30000000000000near view neardtiprooftype.testnet is_valid \
'{"subject_did": "did:near:usuario.testnet", "cid": "bafybeigdyrzi..."}'This contract integrates with the ProofTypeNear class:
const proof = await proofType.generateProof(vcPayload, { wallet, cid });
const valid = await proofType.verifyProof(proof); // true or falseWhere vcPayload includes issuer, credentialSubject.id, and other VC fields.
- Each
subject_did + cidpair can only be issued once. - Overwriting an existing record is not allowed.
- The issuer is tied to the signer of the transaction.
- Network:
testnet - Contract:
neardtiprooftype.testnet - Language: Rust (
near-sdk) - Storage: Optimized by DID and list of CIDs
- License: MIT
cargo build --target wasm32-unknown-unknown --release
near deploy --wasmFile target/wasm32-unknown-unknown/release/prooftype.wasm --accountId neardtiprooftype.testnetThis contract complements the Near DID Registry, which resolves DID documents. The ProofType acts as the attestation capability.