perun-network / erdstall-ts-sdk

TypeScript client SDK to interact with Erdstall.
Apache License 2.0
5 stars 2 forks source link

NFT Metadata Provider/Querier #70

Closed sebastianst closed 3 years ago

sebastianst commented 3 years ago

We should add means to the client to query nft metadata. OpenSea has docs on metadata standards.

The interfaces could look like

interface NFTMetadata {
  name: string;
  description: string;
  image: string; // image URL
  attributes?: []Attribute;
  background_color?: string; // six-char hex
 // ... more optional fields?
}

interface Attribute {
  // please complete with OpenSea metadata standards fields
}

interface NFTMetadataProvider {
  getNftMetadata(token: Address, id: bigint): Promise<NFTMetadata>;
}

For generic NFTs that exist on-chain, the implementation should

  1. query the tokenURI on-chain (and cache it for future requests)
  2. query the metadata on this URI

In the meantime, we should adapt the backend server to conform to this standard (https://github.com/perun-network/nerd-marketplace/issues/100) so we can use the generic implementation also for our PerunArt example contract.

The frontend should then use this functionality from the SDK to display any NFT.