Documentation
¶
Index ¶
- Constants
- Variables
- func ValidateEthereumAddress(address string) error
- type Client
- func (e *Client) BuildTransactOpts(ctx context.Context, l1signer signers.L1Signer) (*bind.TransactOpts, error)
- func (e *Client) NewIERC20Contract(ctx context.Context, address string) (*contracts.IERC20, error)
- func (e *Client) NewIERC721Contract(ctx context.Context, address string) (*contracts.IERC721, error)
- type EtherClient
- type GasParams
Constants ¶
const ( ContractInvalidError = "contract_invalid_error" EthClientError = "ethereum_client_error" )
const ( Retries = 5 Timeout = 5 Fast = "fast" Fastest = "fastest" Average = "average" )
const ( DefaultGasLimit uint64 = 300000 // Ethereum default gas limit in gas units DefaultGasPrice uint64 = 160000000000 // Ethereum default gas price in wei DefaultGasMultiplier float64 = 1.5 // Ethereum default gas multiplier DefaultMaxGasPrice uint64 = 300000000000 // Ethereum max gas price in wei )
Variables ¶
var DefaultGasParams = NewDefaultGasParams()
Functions ¶
func ValidateEthereumAddress ¶
Types ¶
type Client ¶
type Client struct { Client *ethclient.Client RegistrationContract *contracts.Registration CoreContract *contracts.Core GasLimit uint64 GasPrice *big.Int GasMultiplier float64 MaxGasPrice *big.Int EgsAPIKey string EGSSpeed string RegistrationContractAddress ethcommon.Address StarkContractAddress ethcommon.Address }
Client to interact with ethereum blockchain
func NewEthereumClient ¶
NewEthereumClient returns a new ethereum client
func NewEthereumClientAndAttachContracts ¶
func NewEthereumClientAndAttachContracts( ctx context.Context, cfg *config.Config, gasParams GasParams) (*Client, error)
NewEthereumClientAndAttachContracts is a factory method to create a new ethereum client and attaches registration and core contracts to the client.
func (*Client) BuildTransactOpts ¶
func (*Client) NewIERC20Contract ¶
type EtherClient ¶
type GasParams ¶
type GasParams struct { GasLimit uint64 GasPrice *big.Int // GasMultiplier is used to adjust the GasPrice returned by the method SuggestGasPrice (eth_gasPrice) // to control the speed of the ethereum transaction. E.g. a multiplier of 1.5 would set the gas price // at 1.5 times the suggested gas price and should process faster than simply using the suggested gas price. GasMultiplier float64 MaxGasPrice *big.Int // Eth gas station (EGS) API key https://ethgasstation.info EgsAPIKey string // Eth gas station (EGS) speed https://ethgasstation.info EGSSpeed string }
GasParams are used to set the gas limit and gas price. When EgsAPIKey is provided, Client.BuildTransactOpts will attempt to set the gas price returned from eth gas station. If the api call to eth gas station fails, the gas price will be set at the (Network suggested price * GasMultiplier) unless MaxGasPrice is lower, then gas price will be set at MaxGasPrice. When EgsAPIKey is an empty string or if the api call to eth gas station fails, the gas price will be set at the (Network suggested price * GasMultiplier) unless MaxGasPrice is lower, then gas price will be set at MaxGasPrice.
func NewDefaultGasParams ¶
func NewDefaultGasParams() GasParams