EVM Smart Account Design
The design of an EVM Smart Account consists of two main components: the Account Factory Contract and the EntryPoint Contract. These components work together to create and manage accounts on the destination blockchain and execute cross-chain transactions.
Contracts involed:
- Axelar Gateway: A smart contract that connects different blockchains, enabling secure token transfers and communication between them.
- EntryPoint Contract: An Axelar Executable contract that also acts as the entry point for smart accounts. It validates inputs and controls execution.
- Account Factory Contract: A smart contract called once during the setup of a new smart account contract.
- Account Contract: A smart contract owned by the user. It validates execution payloads using the user’s signature and the public key from the source chain before processing.
Smart Account Workflows
There are two main workflows for EVM Smart Accounts:
Account Creation
When a user wants to create an account on the EVM chain, the request is sent to the EntryPoint Contract via the Axelar Gateway. The EntryPoint Contract calls the Account Factory Contract, which creates a new Account Contract on the destination chain. This account is linked to the user’s identity on the source chain.
GMP Payload Structure: The payload sent to the Axelar Gateway specifies the destination chain, the destination address, and the message to be executed.
message := types.Message{
DestinationChain: destinationChain,
DestinationAddress: destinationAddress,
Payload: payload,
Type: generalMessageType,
Fee: feeDetails,
}
Payload Arguments for Account Creation: For account creation, the payload includes the following arguments:
- category: Identifies the action type (account creation).
- recoverAddress: Recovery address that can access the smart account without GMP.
- messageHash: Hash of the transaction message.
- r, s: Signature components from the sender chain.
- x, y: Public key components from the source chain.
arguments := abi.Arguments{
{Type: uint8Type}, // category
{Type: addressType}, // recoverAddress
{Type: bytes32Type}, // messageHash
{Type: bytes32Type}, // r
{Type: bytes32Type}, // s
{Type: bytes32Type}, // x
{Type: bytes32Type}, // y
}
Transaction Execution
When executing a transaction, the Relayer sends a request to the Axelar Gateway to initiate the process. The EntryPoint Contract validates the operation and the sender’s signature. Once validated, the transaction is executed on the Account Contract. This ensures that only authorized transactions are processed.
Payload Arguments for Transaction Execution: For transaction execution, the payload includes the following arguments:
- category: Identifies the action type (transaction execution).
- accountAddress: Address of the smart account.
- messageHash: Hash of the sender chain transaction message.
- r, s: Signature components from the sender chain.
- proof: Hash of the message hash and transaction payload.
- txPayload: Execution data to be processed by the smart account contract.
arguments := abi.Arguments{
{Type: uint8Type}, // category
{Type: addressType}, // accountAddress
{Type: bytes32Type}, // messageHash
{Type: bytes32Type}, // r
{Type: bytes32Type}, // s
{Type: bytes32Type}, // proof
{Type: bytesType}, // txPayload
}