ethrpc

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: LGPL-3.0, MIT Imports: 20 Imported by: 23

Documentation

Index

Constants

View Source
const ENSContractAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"

Variables

View Source
var Networks = map[uint64]Network{
	1: {
		Name:                "mainnet",
		ChainID:             1,
		NumBlocksToFinality: 20,
	},
	3: {
		Name:                "ropsten",
		ChainID:             3,
		NumBlocksToFinality: 20,
	},
	4: {
		Name:                "rinkeby",
		ChainID:             4,
		NumBlocksToFinality: 20,
	},
	5: {
		Name:                "goerli",
		ChainID:             5,
		NumBlocksToFinality: 20,
	},
	42: {
		Name:                "kovan",
		ChainID:             42,
		NumBlocksToFinality: 20,
	},
	137: {
		Name:                "polygon",
		ChainID:             137,
		NumBlocksToFinality: 100,
	},
	80001: {
		Name:                "polygon-mumbai",
		ChainID:             80001,
		NumBlocksToFinality: 100,
	},
	56: {
		Name:                "bsc",
		ChainID:             56,
		NumBlocksToFinality: 50,
	},
	97: {
		Name:                "bsc-testnet",
		ChainID:             97,
		NumBlocksToFinality: 50,
	},
	10: {
		Name:                "optimism",
		ChainID:             10,
		NumBlocksToFinality: 50,
	},
	69: {
		Name:                "optimism-testnet",
		ChainID:             69,
		NumBlocksToFinality: 50,
	},
	42161: {
		Name:                "arbitrum",
		ChainID:             42161,
		NumBlocksToFinality: 50,
	},
	421613: {
		Name:                "arbitrum-testnet",
		ChainID:             421613,
		NumBlocksToFinality: 50,
	},
	42170: {
		Name:                "arbitrum-nova",
		ChainID:             42170,
		NumBlocksToFinality: 50,
	},
	43114: {
		Name:                "avalanche",
		ChainID:             43114,
		NumBlocksToFinality: 50,
	},
	43113: {
		Name:                "avalanche-testnet",
		ChainID:             43113,
		NumBlocksToFinality: 50,
	},
	250: {
		Name:                "fantom",
		ChainID:             250,
		NumBlocksToFinality: 100,
	},
	4002: {
		Name:                "fantom-testnet",
		ChainID:             4002,
		NumBlocksToFinality: 100,
	},
	100: {
		Name:                "gnosis",
		ChainID:             100,
		NumBlocksToFinality: 100,
	},
	1313161554: {
		Name:                "aurora",
		ChainID:             1313161554,
		NumBlocksToFinality: 50,
	},
	1313161556: {
		Name:                "aurora-testnet",
		ChainID:             1313161556,
		NumBlocksToFinality: 50,
	},
}

Functions

func NameHash added in v1.17.8

func NameHash(name string) (hash [32]byte, err error)

NameHash generates a hash from a name that can be used to look up the name in ENS

func Normalize added in v1.17.8

func Normalize(input string) (output string, err error)

Normalize normalizes a name according to the ENS rules

func ResolveEnsAddress added in v1.17.8

func ResolveEnsAddress(ctx context.Context, ens string, provider *Provider) (common.Address, bool, error)

func WaitForTxnReceipt added in v1.3.6

func WaitForTxnReceipt(ctx context.Context, provider *Provider, txHash common.Hash) (*types.Receipt, error)

Types

type Config

type Config struct {
	Nodes []NodeConfig

	ChaindID int // expected ChainID so we confirm on connect..
	TestMode bool
}

func (*Config) AddNode

func (c *Config) AddNode(nodeConfig NodeConfig)

type Network added in v1.17.0

type Network struct {
	Name                string
	ChainID             uint64
	NumBlocksToFinality int
}

type NodeConfig

type NodeConfig struct {
	URL                 string
	MaxRequestPerSecond float64
}

type Provider

type Provider struct {
	*ethclient.Client
	Config *Config
	RPC    *rpc.Client
	// contains filtered or unexported fields
}

func NewProvider

func NewProvider(ethURL string, optClient ...*http.Client) (*Provider, error)

func NewProviderWithConfig

func NewProviderWithConfig(config *Config, optClient ...*http.Client) (*Provider, error)

func (*Provider) BlockByHash added in v1.1.7

func (s *Provider) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

func (*Provider) BlockByNumber

func (s *Provider) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)

func (*Provider) ChainID

func (s *Provider) ChainID(ctx context.Context) (*big.Int, error)

func (*Provider) Dial

func (s *Provider) Dial() error

func (*Provider) QueryContract added in v1.3.4

func (s *Provider) QueryContract(ctx context.Context, contractAddress string, inputAbiExpr, outputAbiExpr string, args interface{}) ([]string, error)

ie, QueryContext(context.Background(), "0xabcdef..", "balanceOf(uint256)", "uint256", []string{"1"}) TODO: add common methods in helpers util, and also use generics to convert the return for us

func (*Provider) SendRawTransaction added in v1.3.6

func (s *Provider) SendRawTransaction(ctx context.Context, signedTxHex string) (common.Hash, error)

func (*Provider) SetHttpClient added in v1.14.4

func (s *Provider) SetHttpClient(httpClient *http.Client)

func (*Provider) TransactionDetails

func (s *Provider) TransactionDetails(ctx context.Context, txnHash common.Hash) (bool, *types.Receipt, *types.Transaction, string, error)

Jump to

Keyboard shortcuts

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