Getting Started
Overview
The package supports storing and reading a hat's metadata from IPFS.
Data is stored in a JSON format, and follows a custom schema which is passed by the user at the client's initialization. By using a schema for the data, we're able to validate that the data is compatible with an expected format.
The package uses the Zod library for the schema definition and validation. The schema is also used for type inference, providing type-safety for its users.
Install
yarn:
npm:
HatsDetailsClient Initialization
A HatsDetailsClient instance is initialized with an IPFS provider (currently only Pinata is supported) and a schema, defined with the Zod library.
Choose which schema to use
Option 1 - use the default schema
If the client is initialized without a custom schema, then the default schema will be used. This schema is compatible with the Hats App, meaning that this app will properly display hats with this type of details.
Here's the default schema:
The corresponding type for this schema is:
Option 2 - use a custom schema
You can define a custom schema for the client, for example:
Set up the Pinata provider
The client is initialized with an IPFS provider that will be used for storing and reading to/from IPFS. Currently, Pinata is the only supported provider and is initialized with the following properties:
pinningKey
- this as a JWT that's used for pinning data, and is required at the client's initialization.gateway
- a dedicated gateway URL, that's provided by Pinata and is used to read IPFS data. This property is optional. If not, provided then the default gateway that's provided by https://ipfs.io will be used.gatewayKey
- optional key that is used to secure dedicated Pinata gateways. If provided along with a gateway, then the key will be used for fetching data.
Last updated