Skip to main content

Famous

famous is a helper package that provides contract addresses for well-known stablecoins across supported networks.

StableCoinSymbol

Typed constant for well-known stablecoin token symbols. Using these constants instead of raw strings prevents typos at compile time.

type StableCoinSymbol string

const (
USDC StableCoinSymbol = "USDC"
USDT StableCoinSymbol = "USDT"
JPYC StableCoinSymbol = "JPYC"
)

ContractAddress

Returns the contract address of a well-known stablecoin on the given network.

func ContractAddress(network types.Network, symbol StableCoinSymbol) (common.Address, error)

Supported Tokens

SymbolNetworks
USDCEthMainnet, PolygonMainnet, PolygonAmoy
USDTEthMainnet, PolygonMainnet
JPYCEthMainnet, PolygonMainnet

Errors

  • famous.ErrNotSupportedNetwork — the network has no registered stablecoin addresses
  • famous.ErrNotSupportedSymbol — the symbol is not registered for the given network

Example

import (
"github.com/poteto-go/go-alchemy-sdk/famous"
"github.com/poteto-go/go-alchemy-sdk/types"
)

func main() {
addr, err := famous.ContractAddress(types.PolygonMainnet, famous.JPYC)
if err != nil {
log.Fatal(err)
}
fmt.Println(addr.Hex())
}

SupportedNetworks

Returns all networks that have at least one registered stablecoin address.

func SupportedNetworks() []types.Network

Example

networks := famous.SupportedNetworks()
for _, n := range networks {
fmt.Println(n)
}

SupportedSymbols

Returns all stablecoin symbols registered for the given network. Returns an empty slice if the network is not supported.

func SupportedSymbols(network types.Network) []StableCoinSymbol

Example

symbols := famous.SupportedSymbols(types.EthMainnet)
for _, s := range symbols {
fmt.Println(s)
}