celoutils

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: AGPL-3.0 Imports: 11 Imported by: 4

README

celoutils

Go test Go Reference

High level Go wrapper for w3 with transaction building utilities among others.

License

AGPL-3.0-or-later

Documentation

Index

Constants

View Source
const (
	CeloContractMainnet = "0x471EcE3750Da237f93B8E339c536989b8978a438"
	CeloContractTestnet = "0xF194afDf50B03e69Bd7D057c1Aa9e10c9954E4C9"

	CUSDContractMainnet = "0x765DE816845861e75A25fCA122bb6898B8B1282a"
	CUSDContractTestnet = "0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1"

	MinGasContractMainnet = "0xDfca3a8d7699D8bAfe656823AD60C17cb8270ECC"
	MinGasContractTestnet = "0xd0Bf87a5936ee17014a057143a494Dc5C5d51E5e"
)
View Source
const (
	MainnetChainId int64 = 42220
	TestnetChainId int64 = 44787
)
View Source
const (
	AccountIndex    = "AccountIndex"
	CustodialProxy  = "CustodialRegistrationProxy"
	GasFaucet       = "GasFaucet"
	TrainingVoucher = "TrainingVoucher"
	TokenIndex      = "TokenIndex"
)
View Source
const (
	ErrInsufficientGas = "w3: call failed: insufficient funds for gas * price + value + gatewayFee"
	ErrGasPriceLow     = "w3: call failed: gasprice is less than gas price minimum floor"
	ErrNonceLow        = "w3: call failed: nonce too low"
)

Common error strings returned by v1 of celo-blockchain nodes.

Variables

View Source
var (
	// SafeGasLimit is set to 350k gas units.
	SafeGasLimit = 350000
	// SafeGasFeeCap is set to 2x the current MinBaseFee of 5 gwei.
	SafeGasFeeCap = big.NewInt(10000000000)
	// SafeGasTipCap is set to 5 wei.
	SafeGasTipCap = big.NewInt(5)
)

Functions

func ChecksumAddress added in v1.1.1

func ChecksumAddress(address string) string

ChecksumAddress converts a mixed case hex address string to a checksumed one.

func HexToAddress added in v1.1.0

func HexToAddress(hexAddress string) common.Address

HexToAddress is similar to common.HexToAddress but converts to a checksumed address first. It is necessary to perform an address validation first before using HexToAddress e.g. with go-playground/validator.

Types

type ContractExecutionTxOpts

type ContractExecutionTxOpts struct {
	ContractAddress common.Address
	InputData       []byte
	GasFeeCap       *big.Int
	GasTipCap       *big.Int
	GasLimit        uint64
	Nonce           uint64
}

type GasTransferTxOpts

type GasTransferTxOpts struct {
	To        common.Address
	Value     *big.Int
	GasFeeCap *big.Int
	GasTipCap *big.Int
	Nonce     uint64
}

type Provider

type Provider struct {
	Client  *w3.Client
	Signer  types.Signer
	ChainId int64
}

func NewProvider

func NewProvider(o ProviderOpts) (*Provider, error)

func (*Provider) RegistryMap added in v1.2.0

func (p *Provider) RegistryMap(ctx context.Context, registryAddress common.Address) (map[string]common.Address, error)

RegistryMap auto-loads all well known custodial related smart contract addresses through the CICRegistry pointer contract.

func (*Provider) SignContractExecutionTx

func (p *Provider) SignContractExecutionTx(privateKey *ecdsa.PrivateKey, txData ContractExecutionTxOpts) (*types.Transaction, error)

func (*Provider) SignGasTransferTx

func (p *Provider) SignGasTransferTx(privateKey *ecdsa.PrivateKey, txData GasTransferTxOpts) (*types.Transaction, error)

type ProviderOpts

type ProviderOpts struct {
	ChainId     int64
	RpcEndpoint string
}

Jump to

Keyboard shortcuts

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