Token Data
Using GraphQL to get Mintbase Token Data

Using TheGraph

TheGraph is an Ethereum indexer that stores aggregated data on IPFS directly from the Ethereum blockchain. When you change the state of the blockchain (mint, transfer, buy, or burn) an event is emitted and then organized by our open sourced mapping tool. Our entire interface hooks into the open query using polling on our React app with Apollo GraphQL, and updates on blockchain confirmations. You can also build your own reporting systems from this.
1
// Websocket
2
wss://api.thegraph.com/subgraphs/name/nategeier/mintbase
3
4
// Query
5
https://api.thegraph.com/subgraphs/name/nategeier/mintbase
6
Copied!
get
https://arweave.net
/:metaId
Fetch Token Metadata on Arweave Gateway

Example:

http://arweave.net/0XReewdXPOzOgb51rhdDqC5gZcUSbvDeKOLeY_ZxKQg
arweave.net
Your can also find the metadata at the end in the url on the Pez Dispenser link
Earlybird Ticket
mintbase

Tracking Your Store

Click the drop down here and you can see example, but just enter your created contract (make sure it's all lowercase)

Things vs Token

A Thing is the batch of tokens (like a cup of coffee) and a Thing will have many to it tokens (15 tokens of a Thing). All these tokens are sharing the same metaId which is the unique idea for a Thing.

Token State:

You'll notice in our graph under s=tokens there is a state field, this is what helps us sell or not sell an item using the buyThing function. If a user sets a price and is for sale anyone can grab that NFT if they throw the price or greater. If no price is set and the token is set for sale, anyone can grab them for free, they just need to pay the transfer gas cost.
State
Type
What the state does
0
Not for Sale
The token can only be airdropped by the minter
1
For Sale
Anyone can grab the token using the buyThing function if enough ETH is sent
2
Sold
Sold and cannot go up for resale on Mintbase, buyThing function no longer works
3
Transferred
Sent after minting buyThing function no longer works

Using React + Apollo

We use Apollo on our React app front end for https://mintbase.io that hooks into the graph query url
Queries
Apollo GraphQL Docs

Realtime Data

We suggest using polling over subscriptions on your quries as theGraph has shown some major delays and websockets can be a nightmare. It's pretty easy to setup.
1
import { useQuery } from "@apollo/react-hooks";
2
3
// Gets all stores from a users eth account
4
// Note to always use lowercase when quiering the graph
5
const useableAccount= '0x66268791b55e1f5fa585d990326519f101407257`
6
const [{ loading, data }] = useQuery(GET_STORES, {
7
variables: { id: useableAccount, approver: process.env.approver },
8
pollInterval: 900
9
});
Copied!
Last modified 1yr ago