eggeth

package
v0.0.0-...-3acd70f Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGasLimit = 30_000_000

Default gas limit when sending transactions.

View Source
const FoundryMnemonic = "test test test test test test test test test test test junk"

Dev mnemonic used by Foundry/Anvil.

Variables

View Source
var (
	AddressCartesiDAppFactory  common.Address
	AddressDAppAddressRelay    common.Address
	AddressERC1155BatchPortal  common.Address
	AddressERC1155SinglePortal common.Address
	AddressERC20Portal         common.Address
	AddressERC721Portal        common.Address
	AddressEtherPortal         common.Address
	AddressInputBox            common.Address
	AddressSunodoToken         common.Address
)

Functions

func DeployTestERC20

func DeployTestERC20(ctx context.Context, endpoint string) (common.Address, error)

Deploy a ERC20 contract for local testing. This function uses the account 0 from the foundry mnemonic to deploy the contract. It returns the the address of the ERC20 contract.

Types

type ETHClient

type ETHClient struct {

	// Gas limit when building transactions.
	GasLimit uint64
	// contains filtered or unexported fields
}

Implements blockchain client for Ethereum using go-ethereum. This struct provides methods that are specific for the Cartesi Rollups.

func NewETHClient

func NewETHClient(endpoint string, dappAddress common.Address) (*ETHClient, error)

Create new ETH client.

func (*ETHClient) ChainID

func (c *ETHClient) ChainID(ctx context.Context) (*big.Int, error)

Get the chain ID.

func (*ETHClient) SendDAppAddress

func (c *ETHClient) SendDAppAddress(ctx context.Context, signer Signer) (int, error)

Send the DApp address to the DApp contract with the DAppAddressRelay contract. This function waits until the transaction is added to a block and return the input index.

func (*ETHClient) SendERC20Tokens

func (c *ETHClient) SendERC20Tokens(
	ctx context.Context,
	signer Signer,
	token common.Address,
	amount *big.Int,
	input []byte,
) (int, error)

Send an ERC20 token to the ERC20 portal. This function also receives an optional input. This function increases the allowance of the sender before sending the token, if necessary. This function waits until the transaction is added to a block and return the input index.

func (*ETHClient) SendEther

func (c *ETHClient) SendEther(
	ctx context.Context,
	signer Signer,
	txValue *big.Int,
	input []byte,
) (int, error)

Send Ether to the Ether portal. This function also receives an optional input. This function waits until the transaction is added to a block and return the input index.

func (*ETHClient) SendInput

func (c *ETHClient) SendInput(ctx context.Context, signer Signer, input []byte) (int, error)

Send the input to the DApp contract. This function waits until the transaction is added to a block and return the input index.

type MnemonicSigner

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

Create a signer by using a mnemonic.

func NewMnemonicSigner

func NewMnemonicSigner(mnemonic string, accountIndex uint32, chainId *big.Int) (
	s *MnemonicSigner, err error)

Create a new mnemonic signer.

func (*MnemonicSigner) Account

func (s *MnemonicSigner) Account() common.Address

func (*MnemonicSigner) MakeTransactor

func (s *MnemonicSigner) MakeTransactor() (*bind.TransactOpts, error)

func (*MnemonicSigner) SetAccount

func (s *MnemonicSigner) SetAccount(accountIndex uint32) error

type Signer

type Signer interface {
	MakeTransactor() (*bind.TransactOpts, error)
	Account() common.Address
}

Interface to create a signer for blockchain transactions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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