utils

package
v0.0.0-...-98563ba Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BscForkClient, _  = rpc.DialContext(context.Background(), "https://rpc.phalcon.blocksec.com/rpc_25d3496386cd49d79e0055b9708af0a6")
	ETHClient, _      = rpc.DialContext(context.Background(), "https://eth-mainnet.g.alchemy.com/v2/qUt8liQq0Kh5rGm9VGGfLfSNLFuONhm3")
	BscClient, _      = rpc.DialContext(context.Background(), "https://binance.llamarpc.com")
	ArbitrumClient, _ = rpc.DialContext(context.Background(), "https://arb-mainnet.g.alchemy.com/v2/vJawUvyo1NE02qYepEe2n_AtjrX_gF5q")
	BaseClient, _     = rpc.DialContext(context.Background(), "https://base-mainnet.g.alchemy.com/v2/7XuVI7nNb8mJFfDc_HlEOiFPVNz4lKAz")
	MerlinClient, _   = rpc.DialContext(context.Background(), "https://rpc.merlinchain.io/api")
	Sender            = common.HexToAddress("0xba46dd807DD7A5bBe2eE80b6D0516A088223C574")
)

Functions

func CalcGasCost

func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int

CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)

func CalculateInterfaceId

func CalculateInterfaceId(contractABI string) []byte

func Call

func Call(ctx context.Context, c *rpc.Client, contract string, method abi.Method) (any, error)

func CallWithInput

func CallWithInput(ctx context.Context, c *rpc.Client, contract, methodName string, abiO *abi.ABI, args ...any) (any, error)

func CodeAt

func CodeAt(ctx context.Context, c *rpc.Client, contract string) (string, error)

func CreateTransaction

func CreateTransaction(ctx context.Context, client *ethclient.Client, sender, to string, value, gas *big.Int, gasLimit uint64, input string) (*types.Transaction, error)

func DecodeABI

func DecodeABI(abiStr string) (*abi.ABI, error)

func IsERC721

func IsERC721()

IsERC721 supportsInterface(0x80ac58cd)是否返回true

func IsValidAddress

func IsValidAddress(addr interface{}) bool

IsValidAddress validate hex address

func IsZeroAddress

func IsZeroAddress(addr interface{}) bool

IsZeroAddress validate if it's a 0 address

func ParseStorageLayout

func ParseStorageLayout(ctx context.Context, c *rpc.Client, contract, storage, abiStr string) (any, error)

func ParseVyPerStorage

func ParseVyPerStorage(ctx context.Context, c *rpc.Client, contract, abiStr string, storageLayout map[string]types.VyPerStorage) ([]types.ContractVariable, error)

func ParseVyPerStorageLayout

func ParseVyPerStorageLayout(ctx context.Context, c *rpc.Client, contract, storage, abiStr string) (any, error)

func PublicKeyBytesToAddress

func PublicKeyBytesToAddress(publicKey []byte) common.Address

PublicKeyBytesToAddress zero address return if key is invalid

func StorageAt

func StorageAt(ctx context.Context, c *rpc.Client, contract string, slot common.Hash) ([]byte, error)

func ToDecimal

func ToDecimal(val any, decimals int) decimal.Decimal

ToDecimal wei to decimals

func ToWei

func ToWei(value any, decimals int) *big.Int

ToWei decimals to wei

func Withdraw

func Withdraw(ctx context.Context, c *rpc.Client, from, to string) error

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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