> ## Documentation Index
> Fetch the complete documentation index at: https://unevenlabs-docs-drift-src-aa153b3060-2d3471a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# EVM Depository Reference

> Solidity API reference for the EVM Relay Depository contract

## 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

```solidity theme={null}
error AddressCannotBeZero()
```

Revert if the address is zero

### InvalidSignature

```solidity theme={null}
error InvalidSignature()
```

Revert if the signature is invalid

### CallRequestExpired

```solidity theme={null}
error CallRequestExpired()
```

Revert if the call request is expired

### CallRequestAlreadyUsed

```solidity theme={null}
error CallRequestAlreadyUsed()
```

Revert if the call request has already been used

### CallFailed

```solidity theme={null}
error CallFailed(bytes returnData)
```

Revert if a call fails

#### Parameters

| Name | Type | Description |
| - | - | - |
| returnData | bytes | The data returned from the failed call |

### RelayNativeDeposit

```solidity theme={null}
event RelayNativeDeposit(address from, uint256 amount, bytes32 id)
```

Emit event when a native deposit is made

#### Parameters

| Name | Type | Description |
| - | - | - |
| from | address | The address that made the deposit |
| amount | uint256 | The amount of native currency deposited |
| id | bytes32 | The unique identifier associated with the deposit |

### RelayErc20Deposit

```solidity theme={null}
event RelayErc20Deposit(address from, address token, uint256 amount, bytes32 id)
```

Emit event when an erc20 deposit is made

#### Parameters

| Name | Type | Description |
| - | - | - |
| from | address | The address that made the deposit |
| token | address | The address of the ERC20 token |
| amount | uint256 | The amount of tokens deposited |
| id | bytes32 | The unique identifier associated with the deposit |

### RelayCallExecuted

```solidity theme={null}
event RelayCallExecuted(bytes32 id, struct Call call)
```

Emit event when a call is executed

#### Parameters

| Name | Type | Description |
| - | - | - |
| id | bytes32 | The identifier of the call request |
| call | struct Call | The call details that were executed |

### \_CALL\_TYPEHASH

```solidity theme={null}
bytes32 _CALL_TYPEHASH
```

The EIP-712 typehash for the Call struct

*Used in structured data hashing for signature verification*

### \_CALL\_REQUEST\_TYPEHASH

```solidity theme={null}
bytes32 _CALL_REQUEST_TYPEHASH
```

The EIP-712 typehash for the CallRequest struct

*Used in structured data hashing for signature verification*

### callRequests

```solidity theme={null}
mapping(bytes32 => bool) callRequests
```

Set of executed call requests

*Maps the hash of a call request to whether it has been executed*

### allocator

```solidity theme={null}
address allocator
```

The allocator address

*Must be set to a secure and trusted entity*

### constructor

```solidity theme={null}
constructor(address _owner, address _allocator) public
```

Initializes the contract with an owner and allocator

#### Parameters

| Name | Type | Description |
| - | - | - |
| \_owner | address | The address that will own the contract |
| \_allocator | address | The address authorized to sign withdrawal requests |

### setAllocator

```solidity theme={null}
function setAllocator(address _allocator) external
```

Set the allocator address

*Only callable by the contract owner*

#### Parameters

| Name | Type | Description |
| - | - | - |
| \_allocator | address | The new allocator address |

### depositNative

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| depositor | address | The address of the depositor - set to `address(0)` to credit `msg.sender` |
| id | bytes32 | The identifier associated with the deposit |

### depositErc20

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| depositor | address | The address of the depositor - set to `address(0)` to credit `msg.sender` |
| token | address | The erc20 token to deposit |
| amount | uint256 | The amount to deposit |
| id | bytes32 | The identifier associated with the deposit |

### depositErc20

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| depositor | address | The address of the depositor - set to `address(0)` to credit `msg.sender` |
| token | address | The erc20 token to deposit |
| id | bytes32 | The identifier associated with the deposit |

### execute

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| request | struct CallRequest | The `CallRequest` to execute |
| signature | bytes | The signature from the allocator |

#### Return Values

| Name | Type | Description |
| - | - | - |
| results | struct CallResult\[] | The results of the calls |

### \_executeCalls

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| id | bytes32 | The identifier of the call request |
| calls | struct Call\[] | The array of calls to execute |

#### Return Values

| Name | Type | Description |
| - | - | - |
| returnData | struct CallResult\[] | The results of each executed call |

### \_hashCallRequest

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| request | struct CallRequest | The `CallRequest` to hash |

#### Return Values

| Name | Type | Description |
| - | - | - |
| structHash | bytes32 | The struct hash |
| eip712Hash | bytes32 | The EIP712 hash |

### \_domainNameAndVersion

```solidity theme={null}
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

| Name | Type | Description |
| - | - | - |
| name | string | The domain name |
| version | string | The version |

## Call

A structure representing a single call to be executed

### Parameters

| Name | Type | Description |
| - | - | - |

```solidity theme={null}
struct Call {
  address to;
  bytes data;
  uint256 value;
  bool allowFailure;
}
```

## CallRequest

A request containing multiple calls to be executed after signature verification

### Parameters

| Name | Type | Description |
| - | - | - |

```solidity theme={null}
struct CallRequest {
  struct Call[] calls;
  uint256 nonce;
  uint256 expiration;
}
```

## CallResult

The result of an executed call

### Parameters

| Name | Type | Description |
| - | - | - |

```solidity theme={null}
struct CallResult {
  bool success;
  bytes returnData;
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.