eth

package
v0.0.0-...-4d27fde Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTestBlock

func NewTestBlock(number *big.Int, txs []*types.Transaction,
	trx []*types.Receipt) *types.Block

NewTestBlock creates a new test block.

func WaitSync

func WaitSync(ctx context.Context, client Client,
	pauseTime time.Duration) error

WaitSync waits for the synchronization of the Geth node.

Types

type Client

type Client interface {
	Accounts(ctx context.Context) ([]string, error)
	SendTransaction(ctx context.Context,
		from, to common.Address, amount *big.Int) (*string, error)
	NetworkID(ctx context.Context) (*big.Int, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
	TransactionReceipt(ctx context.Context,
		txHash common.Hash) (*types.Receipt, error)
	BalanceAt(ctx context.Context, account common.Address,
		blockNumber *big.Int) (*big.Int, error)
	SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
}

Client describes Ethereum client interface.

type GethClient

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

GethClient is an Ethereum JSON-RPC client.

func NewClient

func NewClient(ctx context.Context, url string) (*GethClient, error)

NewClient creates a new Ethereum JSON-RPC client.

func (*GethClient) Accounts

func (c *GethClient) Accounts(ctx context.Context) ([]string, error)

Accounts gets accounts from Geth node.

func (*GethClient) BalanceAt

func (c *GethClient) BalanceAt(ctx context.Context, account common.Address,
	blockNumber *big.Int) (*big.Int, error)

func (*GethClient) BlockByNumber

func (c *GethClient) BlockByNumber(ctx context.Context,
	number *big.Int) (*types.Block, error)

func (*GethClient) Close

func (c *GethClient) Close()

Close closes an Ethereum JSON-RPC client.

func (*GethClient) NetworkID

func (c *GethClient) NetworkID(ctx context.Context) (*big.Int, error)

func (*GethClient) SendTransaction

func (c *GethClient) SendTransaction(ctx context.Context,
	from, to common.Address, amount *big.Int) (result *string, err error)

SendTransaction sends a transaction through Geth node. Account must be unlocked.

func (*GethClient) SyncProgress

func (c *GethClient) SyncProgress(
	ctx context.Context) (*ethereum.SyncProgress, error)

func (*GethClient) TransactionReceipt

func (c *GethClient) TransactionReceipt(ctx context.Context,
	txHash common.Hash) (*types.Receipt, error)

type MockClient

type MockClient struct {
	Acc     map[string]*bind.TransactOpts
	NetID   *big.Int
	Block   *types.Block
	Backend *backends.SimulatedBackend
}

MockClient is a mock for Ethereum client.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient creates a new Ethereum client.

func (*MockClient) Accounts

func (c *MockClient) Accounts(
	ctx context.Context) (result []string, err error)

Accounts is a mock for Accounts function.

func (*MockClient) BalanceAt

func (c *MockClient) BalanceAt(ctx context.Context, account common.Address,
	blockNumber *big.Int) (*big.Int, error)

BalanceAt is a mock for BalanceAt function.

func (*MockClient) BlockByNumber

func (c *MockClient) BlockByNumber(ctx context.Context,
	number *big.Int) (*types.Block, error)

BlockByNumber is a mock for BlockByNumber function.

func (*MockClient) NetworkID

func (c *MockClient) NetworkID(ctx context.Context) (*big.Int, error)

NetworkID is a mock for NetworkID function.

func (*MockClient) SendTransaction

func (c *MockClient) SendTransaction(ctx context.Context,
	from, to common.Address, amount *big.Int) (result *string, err error)

SendTransaction is a mock for SendTransaction function.

func (*MockClient) SyncProgress

func (c *MockClient) SyncProgress(
	ctx context.Context) (*ethereum.SyncProgress, error)

SyncProgress is a mock for SyncProgress function.

func (*MockClient) TransactionReceipt

func (c *MockClient) TransactionReceipt(ctx context.Context,
	txHash common.Hash) (*types.Receipt, error)

TransactionReceipt is a mock for TransactionReceipt function.

type SendTxArgs

type SendTxArgs struct {
	From     string `json:"from"`
	To       string `json:"to"`
	Gas      string `json:"gas"`
	GasPrice string `json:"gasPrice"`
	Value    string `json:"value"`
}

SendTxArgs is an arguments to send transaction.

Jump to

Keyboard shortcuts

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