Loot SDK (for Typescript / Javascript) & Subgraph

The Loot Subgraph and SDK intend to make it easy for anyone to build things that incorporate Loot data.

To install in your JS app, just use:
yarn add loot-sdk or npm install loot-sdk

For information on how to use it check the readme in the Github link below.

Github: https://github.com/shahruz/loot-sdk
npm: loot-sdk - npm

You can also use any GraphQL library in other languages to interact with the subgraph directly.

Github: https://github.com/shahruz/loot-subgraph
Hosted subgraph: https://thegraph.com/legacy-explorer/subgraph/shahruz/loot

Current status
The subgraph includes data on all original Loot that has been minted and info on ownership and trades. The SDK intends to make that data easy for anyone to query without needing to write GraphQL.

The SDK also can be used without any Web3 connections for development of off-chain products or products that don’t require ownership of Loot to use.

Next steps
I’d like to figure out a way to incorporate Synthetics and Derivatives so that developers can incorporate them easily if they choose. I don’t believe either of these structurally make sense to include within the Subgraph at this stage (synthetics don’t have on-chain transactions to monitor, and there are likely too many derivatives to practically maintain a subgraph for).

For Synthetics I think a couple simple APIs can be included for an initial release:

  • getSyntheticLootForAddress(string: address) → returns JS object with Synthetic Loot for that address
  • getRandomSyntheticLoot() → generates a wallet and gets associated Synthetic Loot → returns JS object with SL for that address + wallet info

For Derivatives I’d like to figure out a model that can be expanded on in a consistent way, and used by developers through simple interfaces.
The current plan involves setting up a JSON file in the repo that people can add to via pull requests, containing metadata about derivative contracts, and a mapping to the functions that need to be called to get information (eg. getHead()getHelmet()).

Ideally this can then be used by developers in a simple API that’s consistent with the main getBag() function, like:

  • getBag(number: bagId, string?: derivativeAddress)

If a derivative address is not included, it should default to the original Loot. If a derivative address is included and mapped through the JSON, it should return data for that derivative. If a derivative address is included but not mapped it should throw an error.

I’d appreciate any feedback on the current SDK and subgraph here, as well as thoughts on next steps. :v: