goarbitrum

package module
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

README

arb-provider-go

This Go module allows your client-side Go code to interact with Arbitrum VMs. It is designed to be compatible with the ethclient functionality of go-ethereum.

If your Go-based client code runs with go-ethereum, you can switch to go-arbitrum by finding the go-ethereum ethclient.Dial call that your code is using to connect to Ethereum, and replacing it with a goarbitrum.Dial call.

Specifically, the call to connect to Arbitrum is goarbitrum.Dial(url, myAddress, privateKey, hexPubkey), where url is the URL of an Arbitrum validator you want to connect to (or pass an empty string and it will guess that you want the local URL that arb-deploy uses), myAddress is the Ethereum address you are using, privateKey is the private key corresponding to that address, and hexPubkey is the corresponding public key hex-encoded as by hexutil.Encode.

This package implements the interface necessary to support the code that is produced by the standard abigen tool. But note that some of the less common functions in that interface are not implemented. Trying to call one of the not implemented calls will generate an error that conveys that you have called a functions that is not yet implemented.

Arbitrum technologies are patent pending. This repository is offered under the Apache 2.0 license. See LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Namespace = "Aggregator"

Functions

This section is empty.

Types

type ArbConnection

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

func Dial

func Dial(url string, pk *ecdsa.PrivateKey, rollupAddress common.Address) *ArbConnection

func NewArbConnection added in v0.7.1

func NewArbConnection(connection ValidatorProxy, pk *ecdsa.PrivateKey, rollupAddress common.Address) *ArbConnection

func (*ArbConnection) CallContract

func (conn *ArbConnection) CallContract(
	ctx context.Context,
	call ethereum.CallMsg,
	blockNumber *big.Int,
) ([]byte, error)

CallContract executes an Ethereum contract call with the specified data as the input.

func (*ArbConnection) CodeAt

func (conn *ArbConnection) CodeAt(
	ctx context.Context,
	contract ethcommon.Address,
	blockNumber *big.Int,
) ([]byte, error)

CodeAt returns the code of the given account. This is needed to differentiate between contract internal errors and the local chain being out of sync.

func (*ArbConnection) EstimateGas

func (conn *ArbConnection) EstimateGas(
	ctx context.Context,
	call ethereum.CallMsg,
) (uint64, error)

EstimateGas tries to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*ArbConnection) FilterLogs

func (conn *ArbConnection) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)

TODO: Currently FilterLogs does not properly handle reorgs by replaying undone logs with the removed flag set

func (*ArbConnection) PendingCallContract added in v0.4.0

func (conn *ArbConnection) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)

PendingCallContract executes an Ethereum contract call against the pending state.

func (*ArbConnection) PendingCodeAt

func (conn *ArbConnection) PendingCodeAt(
	ctx context.Context,
	account ethcommon.Address,
) ([]byte, error)

PendingCodeAt returns the code of the given account in the pending state.

func (*ArbConnection) PendingNonceAt

func (conn *ArbConnection) PendingNonceAt(
	ctx context.Context,
	account ethcommon.Address,
) (uint64, error)

PendingNonceAt retrieves the current pending nonce associated with an account.

func (*ArbConnection) SendTransaction

func (conn *ArbConnection) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction injects the transaction into the pending pool for execution.

func (*ArbConnection) SubscribeFilterLogs

func (conn *ArbConnection) SubscribeFilterLogs(
	ctx context.Context,
	query ethereum.FilterQuery,
	ch chan<- types.Log,
) (ethereum.Subscription, error)

SubscribeFilterLogs creates a background log filtering operation, returning a subscription immediately, which can be used to stream the found events.

func (*ArbConnection) SuggestGasPrice

func (conn *ArbConnection) SuggestGasPrice(_ context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*ArbConnection) TransactionReceipt added in v0.4.0

func (conn *ArbConnection) TransactionReceipt(ctx context.Context, txHash ethcommon.Hash) (*types.Receipt, error)

TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.

type ValidatorProxy

type ValidatorProxy interface {
	GetBlockCount(ctx context.Context) (uint64, error)
	SendTransaction(ctx context.Context, tx *types.Transaction) (common.Hash, error)
	BlockInfo(ctx context.Context, height uint64) (*machine.BlockInfo, error)
	BlockHash(ctx context.Context, height uint64) (common.Hash, error)
	GetRequestResult(ctx context.Context, txHash common.Hash) (value.Value, error)
	GetChainAddress(ctx context.Context) (ethcommon.Address, error)
	FindLogs(ctx context.Context, fromHeight, toHeight *uint64, addresses []ethcommon.Address, topics [][]ethcommon.Hash) ([]evm.FullLog, error)
	Call(ctx context.Context, msg message.Call, sender ethcommon.Address) (value.Value, error)
	PendingCall(ctx context.Context, msg message.Call, sender ethcommon.Address) (value.Value, error)
}

func NewValidatorProxyImpl

func NewValidatorProxyImpl(url string) ValidatorProxy

type ValidatorProxyImpl

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

func (*ValidatorProxyImpl) BlockHash added in v0.7.1

func (vp *ValidatorProxyImpl) BlockHash(ctx context.Context, height uint64) (common.Hash, error)

func (*ValidatorProxyImpl) BlockInfo added in v0.7.1

func (vp *ValidatorProxyImpl) BlockInfo(ctx context.Context, height uint64) (*machine.BlockInfo, error)

func (*ValidatorProxyImpl) Call added in v0.7.1

func (*ValidatorProxyImpl) FindLogs

func (vp *ValidatorProxyImpl) FindLogs(ctx context.Context, fromHeight, toHeight *uint64, addresses []ethcommon.Address, topicGroups [][]ethcommon.Hash) ([]evm.FullLog, error)

func (*ValidatorProxyImpl) GetBlockCount added in v0.7.1

func (vp *ValidatorProxyImpl) GetBlockCount(ctx context.Context) (uint64, error)

func (*ValidatorProxyImpl) GetChainAddress added in v0.7.1

func (vp *ValidatorProxyImpl) GetChainAddress(ctx context.Context) (ethcommon.Address, error)

func (*ValidatorProxyImpl) GetRequestResult added in v0.7.1

func (vp *ValidatorProxyImpl) GetRequestResult(ctx context.Context, txHash common.Hash) (value.Value, error)

func (*ValidatorProxyImpl) PendingCall added in v0.6.0

func (vp *ValidatorProxyImpl) PendingCall(ctx context.Context, msg message.Call, sender ethcommon.Address) (value.Value, error)

func (*ValidatorProxyImpl) SendTransaction added in v0.7.1

func (vp *ValidatorProxyImpl) SendTransaction(ctx context.Context, tx *types.Transaction) (common.Hash, error)

Jump to

Keyboard shortcuts

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