token

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

Token Metadata for Go

Usage

Import this repo directly into your own go repo

Maintain

  1. update token meta submodule by git submodule update --remote --merge
  2. run make gen to copy static token meta file to embed
  3. develop your new util functions
  4. don't forget to run make build to make sure no error in compiling at least ps: better to not edit & push submodule to remote

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlchemyRequest added in v0.0.3

type AlchemyRequest struct {
	JsonRPC string `json:"jsonrpc"`
	ID      int    `json:"id"`

	Method string   `json:"method"`
	Params []string `json:"params"`
}

type Dict

type Dict map[string]*Token

type EthereumAddress

type EthereumAddress struct {
	common.Address
}

type Meta

type Meta struct {
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
	Decimals int    `json:"decimals"`
}

Meta this struct is the same as the metadata in the resp of Alchemy

type MetadataResponse added in v0.0.3

type MetadataResponse struct {
	JsonRPC string `json:"jsonrpc"`
	ID      int    `json:"id"`

	Error  *RPCError `json:"error"`
	Result *Meta     `json:"result"`
}

type RPCError added in v0.0.3

type RPCError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Token

type Token struct {
	Address     string `json:"address"`
	CoingeckoID string `json:"coinGeckoId"`
	Meta        *Meta  `json:"meta"`
}

func GetTokenByAddress

func GetTokenByAddress(address string) *Token

GetTokenByAddress no case sensitivity, and it's safe to pass address with prefix "peggy" for unknown address, request metadata from alchemy

func GetTokenBySymbol

func GetTokenBySymbol(symbol string) *Token

GetTokenBySymbol no case sensitivity, USD/usd/Usd are all fine

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL