Parsing Attestation Data
Attestation data is encoded into a single hex string and can be decoded if you know the schema used to encode the data. With attestations on Sign Protocol, the attestation object returned also includes the schema's structure, which is exactly what we need.
NOTE: If you selected a data storage option that is not directly on-chain (such as Arweave/IPFS), your schema will utilize Hybrid Attestations. Our SDK will handle this for you but note that you will receive an encoded Content ID (CID) as data
when retrieving a hybrid attestation.
We will write a function that takes in a message and the list of attestations returned from our query. This function will find the specific attestation we are looking for and return it with the parsed data object.
You can use our NPM SDK's decodeOnChainData
function to decode your attestation data rather than directly interfacing with viem's decodeAbiParameters
as shown in this tutorial. For more information and an example, see here.
Now, we can parse the attestations returned from our query to Sign Protocol's Indexing Service, perform additional checks, and utilize the data they contain. In our example, we can perform some action using Alice's attestation of Bob's signature, or display an error if no such valid attestation is found.
If you know the attestation or schema you are looking for, you can also directly request its data from the Sign Protocol Indexing Service. In our case, we were looking for an attestation that met certain criteria. To expand upon our example, if our application was responsible for creating Alice's attestation, it might make sense to store the returned ID in a database for quicker load times (querying will always take longer than direct access with an ID, even if marginally so).
Finished Tutorial
You can find the finished tutorial implementation here.
Last updated