client

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

package client provides API for communication with an Ethereum blockchain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client defines necessary attributes for establishing communication with an Ethereum blockchain and for performing functions required by the Nym system.

func New

func New(cfg Config) (*Client, error)

func (*Client) EtherToWei

func (c *Client) EtherToWei(ether *big.Float) *big.Int

func (*Client) GetTransactionStatus

func (c *Client) GetTransactionStatus(ctx context.Context, txHash common.Hash) TxStatus

used to get status of transaction, pending, accepted, rejected, etc

func (*Client) QueryERC20Balance

func (c *Client) QueryERC20Balance(ctx context.Context, address common.Address, pending bool) (*big.Int, error)

pending is used to decide whether to query pending balance

func (*Client) QueryEtherBalance

func (c *Client) QueryEtherBalance(ctx context.Context, address common.Address, blockNumber *big.Int) (*big.Int, error)

for nil blockNumber, latest known is used

func (*Client) TransferERC20Tokens

func (c *Client) TransferERC20Tokens(ctx context.Context,
	amount int64,
	targetAddress common.Address,
	tokenDecimals ...int,
) (common.Hash, error)

TransferERC20Tokens sends specified amount of ERC20 tokens to given account.

func (*Client) TransferEther

func (c *Client) TransferEther(ctx context.Context, toAddress common.Address, amount float64) (common.Hash, error)

type Config

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

Config defines configuration for Ethereum Client. TODO: if expands too much, move it to a toml file? Or just include it in new section of existing Client toml.

func NewConfig

func NewConfig(pk *ecdsa.PrivateKey, node string, erc20, pipeAccount common.Address, logger *logger.Logger) Config

NewConfig creates new instance of Config struct.

type TxStatus

type TxStatus byte
const (
	TxStatusUnknown  TxStatus = 0
	TxStatusAccepted TxStatus = 1
	TxStatusRejected TxStatus = 2
	TxStatusPending  TxStatus = 3
)

Jump to

Keyboard shortcuts

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