Skip to content

Commit

Permalink
Example for verifying an Off-chain Attestation
Browse files Browse the repository at this point in the history
  • Loading branch information
slavik0329 committed Aug 17, 2023
1 parent 0cf8c52 commit 5f7d3ca
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,59 @@ const transaction = await eas.multiRevokeOffchain([data1, data2]);
await transaction.wait();
```

### Verify an Off-chain Attestation

To verify an off-chain attestation, you can use the `verifyOffchainAttestationSignature` function provided by the EAS SDK. Here's an example:

```javascript
import { OFFCHAIN_ATTESTATION_VERSION, Offchain, PartialTypedDataConfig } from "@ethereum-attestation-service/eas-sdk";

const attestation = {
// your offchain attestation
sig: {
domain: {
name: "EAS Attestation",
version: "0.26",
chainId: 1,
verifyingContract: "0xA1207F3BBa224E2c9c3c6D5aF63D0eb1582Ce587",
},
primaryType: "Attest",
types: {
Attest: [],
},
signature: {
r: "",
s: "",
v: 28,
},
uid: "0x5134f511e0533f997e569dac711952dde21daf14b316f3cce23835defc82c065",
message: {
version: 1,
schema: "0x27d06e3659317e9a4f8154d1e849eb53d43d91fb4f219884d1684f86d797804a",
refUID: "0x0000000000000000000000000000000000000000000000000000000000000000",
time: 1671219600,
expirationTime: 0,
recipient: "0xFD50b031E778fAb33DfD2Fc3Ca66a1EeF0652165",
attester: "0x1e3de6aE412cA218FD2ae3379750388D414532dc",
revocable: true,
data: "0x0000000000000000000000000000000000000000000000000000000000000000",
},
},
signer: "0x1e3de6aE412cA218FD2ae3379750388D414532dc",
};

const EAS_CONFIG: PartialTypedDataConfig = {
address: attestation.sig.domain.verifyingContract,
version: attestation.sig.domain.version,
chainId: attestation.sig.domain.chainId,
};
const offchain = new Offchain(EAS_CONFIG, OFFCHAIN_ATTESTATION_VERSION);
const isValidAttestation = offchain.verifyOffchainAttestationSignature(
attestation.signer,
attestation.sig
);
```

### Registering a Schema

To register a new schema, you can use the `register` function provided by the EAS SDK. This function takes an object with the following properties:
Expand Down

0 comments on commit 5f7d3ca

Please sign in to comment.