Mint Provider

πŸ“˜ Mint info Provider

API

<MintProvider> ... </MintProvider>
Property
Type
Description
Default

children

ReactNode

The wrapped children.

undefined

For example

import { MintProvider } from '@sentre/senhub'

// Wrap a paragraph as a child.
<MintProvider>
  <p>Hello world</p>
</MintProvider>

Context

type Provider {
  mints: State
  getMint: (mintAddress: string) => Promise<MintData>
  getDecimals: (mintAddress: string) => Promise<number>
  tokenProvider: TokenProvider
}

type State = Record<string, MintData>
type MintData = {
  mint_authority_option: number;
  mint_authority: string;
  supply: bigint;
  decimals: number;
  is_initialized: boolean;
  freeze_authority_option: number;
  freeze_authority: number;
}
type TokenProvider = any // See the table below

Provider

Property
Type
Description

mints

Record<string, MintData>

A mapping from a mint address to the corresponding mint data.

getMint

async (mintAddress: string): Promise<MintData>

Fetch mint data from live nodes or local cache by a mint address.

getDecimals

async (mintAddress: string): Promise<number>

Find decimals for the mint.

tokenProvider

TokenProvider

The mint metadata provider (i.e. logo uri, coingecko or coinmarketcap ticket). See the TokenProvider section for details.

MintData

Property
Type
Description

mint_authority_option

0 | 1

Whether the mint_authority property is available.

mint_authority

string

The authority address that can mint more token.

supply

bigint

Total supply.

decimals

number

Decimals.

is_initialized

boolean

Whether the mint is initialized.

freeze_authority_option

bigint

Whether the freeze_authority property is available.

freeze_authority

string

The authority address that can freeze accounts corresponding to the mint.

Hook & HOC

For example

Wrap the parent by MintProvider before accessing the context.

TokenProvider

In this document, we will use token and mint interchangeably. However, the meaning of both is the same.

Actually, tokenProvider is an instance from TokenProvider class. By the instance, you can find token metadata by its symbol or name for example. That way is more intuitive than using mint addresses.

TokenProvider API

Property
Type
Description

find

async (keyword: string, limit?: 10): Promise<TokenInfo[]>

Semantic search tokens. The function can search mutiple tokens.

findByAddress

async (addr: string): Promise<TokenInfo | undefined>

Find a token by its address.

all

async (): Promise<TokenInfo[]>

Get all tokens.

You can learn more data types in the original repo: https://github.com/solana-labs/token-list.

TokenInfo

Example: all

Example: findByAddress

Example: find

Last updated