ethereum

package
v0.0.0-...-13b53a3 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const SHOULD_LOG_WARNINGS = true

Variables

View Source
var ERC20ABI, _ = contracts.ERC20MetaData.GetAbi()
View Source
var ERC20ALTABI, _ = contracts.Erc20AltMetaData.GetAbi()
View Source
var MulticallClientForChainID = make(map[uint64]TEthMultiCaller)

MulticallClientForChainID holds the multicall client for a specific chainID

View Source
var RPC = map[uint64]*ethclient.Client{}

RPC contains the ethclient.Client for a specific chainID

View Source
var RPC_ENDPOINTS = map[uint64]string{}

RPC_ENDPOINTS contains the node endpoints to connect the blockchains

Functions

func DecodeHex

func DecodeHex(something []interface{}, fallback string) string

DecodeHex decodes a hax from a slice of interfaces and try to convert it to a string

func DecodeString

func DecodeString(something []interface{}, fallback string) string

DecodeString decodes a string from a slice of interfaces

func DecodeUint64

func DecodeUint64(something []interface{}, fallback uint64) uint64

DecodeUint64 decodes a uint64 from a slice of interfaces

func FetchBasicInformations

func FetchBasicInformations(chainID uint64, tokens []common.Address) map[string]*TERC20

func FetchDecimals

func FetchDecimals(chainID uint64, tokens []common.Address) map[string]uint64

func FetchNames

func FetchNames(chainID uint64, tokens []common.Address) map[string]string

func GetRPC

func GetRPC(chainID uint64) *ethclient.Client

GetRPC returns the current connection for a specific chain

func GetRPCURI

func GetRPCURI(chainID uint64) string

GetRPCURI returns the URI to use to connect to the node for a specific chainID

func Init

func Init()

Types

type Call

type Call struct {
	Name     string         `json:"name"`
	Method   string         `json:"method"`
	Version  string         `json:"version"`
	Abi      *abi.ABI       `json:"abi"`
	Target   common.Address `json:"target"`
	CallData []byte         `json:"call_data"`
}

func (Call) GetMultiCall

func (call Call) GetMultiCall() contracts.Multicall3Call

type CallResponse

type CallResponse struct {
	Success    bool   `json:"success"`
	ReturnData []byte `json:"returnData"`
}

type TERC20

type TERC20 struct {
	Address  common.Address
	Name     string
	Symbol   string
	ChainID  uint64
	Decimals uint64
}

************************************************************************************************* ** fetchBasicInformations will, for a list of addresses, fetch all the relevant basic information ** for the related token. This includes the name, the symbol and the decimals. ** ** Arguments: ** - chainID: the chain ID of the network we are working on ** - tokens: a list of addresses of the tokens we want to fetch the information for ** ** Returns: ** - a list of TERC20Token containing the basic information for the tokens *************************************************************************************************

type TEthMultiCaller

type TEthMultiCaller struct {
	Signer          *bind.TransactOpts
	Client          *ethclient.Client
	Abi             *abi.ABI
	ContractAddress common.Address
}

func NewMulticall

func NewMulticall(rpcURI string, multicallAddress common.Address) TEthMultiCaller

NewMulticall creates a new instance of a TEthMultiCaller. This is the instance we will later use to perform multiple ethereum calls batched in the same transaction. For performance reason, this should be initialized once and then reused.

func (*TEthMultiCaller) ExecuteByBatch

func (caller *TEthMultiCaller) ExecuteByBatch(
	calls []Call,
	batchSize uint64,
	blockNumber *big.Int,
) map[string][]interface{}

ExecuteByBatch will take a group of calls, split them in fixed-size group to avoid the gasLimit error, and execute as many transactions as required to get the results

Jump to

Keyboard shortcuts

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