evm

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxGasLimit is the maximum gas limit for a transaction in wei
	MaxGasLimit = 70000
	MaxGasPrice = 25000000000
)
View Source
const (
	EVMAssetDecimals         = 18
	TransferFeeCoeff float64 = 1.007
)

Variables

Functions

func AddressPublic

func AddressPublic(address string, mnemonic string, passphrase string, sequence uint32) (string, error)

func AddressSecret

func AddressSecret(address string, mnemonic string, passphrase string, sequence uint32) (string, error)

func AddressWallet

func AddressWallet(mnemonic string, passphrase string, sequence uint32) (string, error)

func GetBaseFeeMultiplier

func GetBaseFeeMultiplier(baseFeeWei decimal.Decimal) decimal.Decimal

func ValidateAddress

func ValidateAddress(address string) bool

func WalletPubKeyHash

func WalletPubKeyHash(mnemonic string, passphrase string, sequence uint32) (string, *btcec.PrivateKey, *btcec.PublicKey, error)

Types

type Config

type Config struct {
	NodeAddr   string
	RPCOptions []rpc.ClientOption
	Blockchain wconstants.BlockchainType
}

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the config is valid

type EVM

type EVM struct {
	// contains filtered or unexported fields
}

func NewEVM

func NewEVM(ctx context.Context, conf Config) (*EVM, error)

func (*EVM) Blockchain

func (s *EVM) Blockchain() wconstants.BlockchainType

Blockchain returns the blockchain type

func (*EVM) EstimateFee

func (s *EVM) EstimateFee(ctx context.Context) (*EstimateFeeResult, error)

func (*EVM) EstimateTransfer

func (s *EVM) EstimateTransfer(ctx context.Context, fromAddress, toAddress, assetIdentifier string, amount decimal.Decimal, decimals int64) (*EstimateTransferResult, error)

EstimateTransfer estimates the transfer fee. Amount is in Eth

func (*EVM) Name

func (s *EVM) Name() string

Name returns the service name

func (*EVM) Node

func (s *EVM) Node() *ethclient.Client

Node returns the grpc client

func (*EVM) Start

func (s *EVM) Start(_ context.Context) error

Start

func (*EVM) Stop

func (s *EVM) Stop(_ context.Context) error

Stop

type EstimateFeeResult

type EstimateFeeResult struct {
	// MaxFeePerGas is the maximum fee per gas in Wei
	MaxFeePerGas decimal.Decimal `json:"max_fee_per_gas"`
	// SuggestGasTipCap is the suggested gas tip cap in Wei
	SuggestGasTipCap decimal.Decimal `json:"suggest_gas_tip_cap"`
	// SuggestGasPrice is the suggested gas price in Wei
	SuggestGasPrice decimal.Decimal `json:"suggest_gas_price"`
}

EstimateFeeResult represents the result of the fee estimation

All values are in Wei

type EstimateTransferResult

type EstimateTransferResult struct {
	Estimate          EstimateFeeResult `json:"estimate"`
	EstimateGasAmount decimal.Decimal   `json:"estimate_gas_amount"`
	TotalFeeAmount    decimal.Decimal   `json:"total_fee_amount"`
	TotalGasPrice     decimal.Decimal   `json:"total_gas_price"`
	GasTipCap         decimal.Decimal   `json:"gas_tip_cap"`
}

type EtherUnit

type EtherUnit int
const (
	EtherUnitWei EtherUnit = iota
	EtherUnitKWei
	EtherUnitMWei
	EtherUnitGWei
	EtherUnitSzabo
	EtherUnitFinney
	EtherUnitEther
)

type Unit

type Unit struct {
	// contains filtered or unexported fields
}

Unit represents a currency value in the Ethereum blockchain. by default, the value is in Wei.

func NewUnit

func NewUnit(value decimal.Decimal, baseUnit EtherUnit) Unit

NewUnit creates a new currency value with the given value and unit.

func NewUnitFromBigInt

func NewUnitFromBigInt(value *big.Int, unit EtherUnit) Unit

NewUnitFromBigInt creates a new currency value with the given big integer value and unit.

func (Unit) BigInt

func (c Unit) BigInt() *big.Int

BigInt returns the big integer representation of the currency value.

func (Unit) Decimal

func (c Unit) Decimal() decimal.Decimal

Decimal returns the decimal representation of the currency value.

func (Unit) String

func (c Unit) String() string

String returns the string representation of the currency value.

func (Unit) Value

func (c Unit) Value(unit EtherUnit) Unit

Value returns the currency value in the given unit.

type WalletSDK

type WalletSDK struct{}

func NewWalletSDK

func NewWalletSDK() *WalletSDK

NewWalletSDK creates a new WalletSDK instance.

func (WalletSDK) ValidateAddress

func (s WalletSDK) ValidateAddress(address string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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