Documentation ¶
Overview ¶
A high-level framework for Cartesi rollups in Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Roll ¶
func Roll(contract MiddlewareContract)
Start the Cartesi rollups for the contract. This function doesn't return and exits if there is an error.
Types ¶
type Client ¶
type Client struct { ClientConfig Eth *eggeth.ETHClient // contains filtered or unexported fields }
The client interacts with the DApp contract off-chain.
func NewClient ¶
func NewClient(config ClientConfig) (*Client, error)
Create a new client with the given config.
func NewDevClient ¶
Create a new client for local development. Connects to the Rollups Node and the Ethereum Node setup by sunodo. Return a signer that uses the Foundry's test mnemonic to send transactions.
type ClientConfig ¶
type ClientConfig struct { DAppAddress common.Address GraphqlEndpoint string InspectEndpoint string ProviderEndpoint string }
Configuration for the client struct.
type Env ¶
type Env interface { EnvReader // Get the Metadata for the current input. Metadata() *rollups.Metadata // Get the deposit for the current input if it came from a portal. Deposit() eggwallets.Deposit // Get the original sender for the current input. // If the input sender was a portal, this function returns the address that called the portal. Sender() common.Address // Send a voucher. Return the voucher's index. Voucher(destination common.Address, payload []byte) int // Send a notice. Return the notice's index. Notice(payload []byte) int // Transfer the given amount of funds from source to destination. // Return error if the source doesn't have enough funds. EtherTransfer(src common.Address, dst common.Address, value *big.Int) error // Withdraw the asset from the wallet and generate the voucher to withdraw from the portal. // Return the voucher index. // Return error if the address doesn't have enough assets. EtherWithdraw(address common.Address, value *big.Int) (int, error) // Transfer the given amount of tokens from source to destination. // Return error if the source doesn't have enough funds. ERC20Transfer(token common.Address, src common.Address, dst common.Address, value *big.Int) error // Withdraw the asset from the wallet and generate the voucher to withdraw from the portal. // Return error if the address doesn't have enough assets. ERC20Withdraw(token common.Address, address common.Address, value *big.Int) (int, error) }
Read and write the rollups environment. This interface will be passed to the contract advance method.
type EnvReader ¶
type EnvReader interface { // Get the DApp address. // The address is initialized after the contract receives an input from // the AddressRelay contract. DAppAddress() *common.Address // Send a report to the Rollups API. // Reports can be any array of bytes, and are save even when the // contract revers the input. Report(payload []byte) // Call fmt.Sprint, print the log, and send a report encoded as eggtypes.Log. Log(a ...any) // Call fmt.Sprintf, print the log, and send a report encoded as eggtypes.Log. Logf(format string, a ...any) // Call fmt.Sprint, print the log, and send a report encoded as eggtypes.Error. Error(a ...any) // Call fmt.Sprintf, print the log, and send a report encoded as eggtypes.Error. Errorf(format string, a ...any) // Call fmt.Sprint, print the log, send a report encoded as eggtypes.Error, and exit. Fatal(a ...any) // Call fmt.Sprintf, print the log, send a report encoded as eggtypes.Error, and exit. Fatalf(format string, a ...any) // Return the list of addresses that have assets. EtherAddresses() []common.Address // Return the balance of the given address. EtherBalanceOf(address common.Address) *big.Int // Return the list of tokens with assets. ERC20Tokens() []common.Address // Return the list of addresses that have assets for the given token. ERC20Addresses(token common.Address) []common.Address // Return the balance of the given address for the given token. ERC20BalanceOf(token common.Address, address common.Address) *big.Int }
Read from the rollups environment. This interface will be passed to the contract inspect method.
type MiddlewareContract ¶
type MiddlewareContract interface { // Advance the contract state. Advance(env Env, input []byte) error // Inspect the contract state. Inspect(env EnvReader, input []byte) error }
The MiddlewareContract is the on-chain part of a rollups DApp. EggRoll uses the contract's codecs to encode the input and return values. For the advance and inspect methods, if the return value is []byte, return the raw bytes. If the call returns an error, EggRoll rejects the input.