Solidity API

EVM Relay Depository

Provides secure deposit functionality and execution of allocator-signed requests for EVM chains EVM implementation using EIP-712 for structured data signing, supporting native ETH and ERC20 tokens

AddressCannotBeZero

error AddressCannotBeZero()
Revert if the address is zero

InvalidSignature

error InvalidSignature()
Revert if the signature is invalid

CallRequestExpired

error CallRequestExpired()
Revert if the call request is expired

CallRequestAlreadyUsed

error CallRequestAlreadyUsed()
Revert if the call request has already been used

CallFailed

error CallFailed(bytes returnData)
Revert if a call fails

Parameters

NameTypeDescription
returnDatabytesThe data returned from the failed call

RelayNativeDeposit

event RelayNativeDeposit(address from, uint256 amount, bytes32 id)
Emit event when a native deposit is made

Parameters

NameTypeDescription
fromaddressThe address that made the deposit
amountuint256The amount of native currency deposited
idbytes32The unique identifier associated with the deposit

RelayErc20Deposit

event RelayErc20Deposit(address from, address token, uint256 amount, bytes32 id)
Emit event when an erc20 deposit is made

Parameters

NameTypeDescription
fromaddressThe address that made the deposit
tokenaddressThe address of the ERC20 token
amountuint256The amount of tokens deposited
idbytes32The unique identifier associated with the deposit

RelayCallExecuted

event RelayCallExecuted(bytes32 id, struct Call call)
Emit event when a call is executed

Parameters

NameTypeDescription
idbytes32The identifier of the call request
callstruct CallThe call details that were executed

_CALL_TYPEHASH

bytes32 _CALL_TYPEHASH
The EIP-712 typehash for the Call struct Used in structured data hashing for signature verification

_CALL_REQUEST_TYPEHASH

bytes32 _CALL_REQUEST_TYPEHASH
The EIP-712 typehash for the CallRequest struct Used in structured data hashing for signature verification

callRequests

mapping(bytes32 => bool) callRequests
Set of executed call requests Maps the hash of a call request to whether it has been executed

allocator

address allocator
The allocator address Must be set to a secure and trusted entity

constructor

constructor(address _owner, address _allocator) public
Initializes the contract with an owner and allocator

Parameters

NameTypeDescription
_owneraddressThe address that will own the contract
_allocatoraddressThe address authorized to sign withdrawal requests

setAllocator

function setAllocator(address _allocator) external
Set the allocator address Only callable by the contract owner

Parameters

NameTypeDescription
_allocatoraddressThe new allocator address

depositNative

function depositNative(address depositor, bytes32 id) external payable
Deposit native tokens and emit a RelayNativeDeposit event Emits a RelayNativeDeposit event with the deposit details

Parameters

NameTypeDescription
depositoraddressThe address of the depositor - set to address(0) to credit msg.sender
idbytes32The identifier associated with the deposit

depositErc20

function depositErc20(address depositor, address token, uint256 amount, bytes32 id) public
Deposit erc20 tokens and emit an RelayErc20Deposit event Transfers tokens from msg.sender to this contract and emits a RelayErc20Deposit event

Parameters

NameTypeDescription
depositoraddressThe address of the depositor - set to address(0) to credit msg.sender
tokenaddressThe erc20 token to deposit
amountuint256The amount to deposit
idbytes32The identifier associated with the deposit

depositErc20

function depositErc20(address depositor, address token, bytes32 id) external
Deposit erc20 tokens and emit an RelayErc20Deposit event Uses the full allowance granted to this contract and calls depositErc20

Parameters

NameTypeDescription
depositoraddressThe address of the depositor - set to address(0) to credit msg.sender
tokenaddressThe erc20 token to deposit
idbytes32The identifier associated with the deposit

execute

function execute(struct CallRequest request, bytes signature) external returns (struct CallResult[] results)
Execute a CallRequest signed by the allocator Verifies the signature, expiration, and uniqueness before execution

Parameters

NameTypeDescription
requeststruct CallRequestThe CallRequest to execute
signaturebytesThe signature from the allocator

Return Values

NameTypeDescription
resultsstruct CallResult[]The results of the calls

_executeCalls

function _executeCalls(bytes32 id, struct Call[] calls) internal returns (struct CallResult[] returnData)
Internal function to execute a list of calls Handles multiple calls and properly manages failures based on allowFailure flag

Parameters

NameTypeDescription
idbytes32The identifier of the call request
callsstruct Call[]The array of calls to execute

Return Values

NameTypeDescription
returnDatastruct CallResult[]The results of each executed call

_hashCallRequest

function _hashCallRequest(struct CallRequest request) internal view returns (bytes32 structHash, bytes32 eip712Hash)
Helper function to hash a CallRequest and return the EIP-712 digest Implements EIP-712 structured data hashing for the complex CallRequest type

Parameters

NameTypeDescription
requeststruct CallRequestThe CallRequest to hash

Return Values

NameTypeDescription
structHashbytes32The struct hash
eip712Hashbytes32The EIP712 hash

_domainNameAndVersion

function _domainNameAndVersion() internal pure returns (string name, string version)
Returns the domain name and version of the contract to be used in the domain separator Implements required function from EIP712 base contract

Return Values

NameTypeDescription
namestringThe domain name
versionstringThe version

Call

A structure representing a single call to be executed

Parameters

NameTypeDescription
struct Call {
  address to;
  bytes data;
  uint256 value;
  bool allowFailure;
}

CallRequest

A request containing multiple calls to be executed after signature verification

Parameters

NameTypeDescription
struct CallRequest {
  struct Call[] calls;
  uint256 nonce;
  uint256 expiration;
}

CallResult

The result of an executed call

Parameters

NameTypeDescription
struct CallResult {
  bool success;
  bytes returnData;
}