Build
Architecture
protocol
contracts
zevm
GatewayZEVM.sol
Contract.gatewayzevm

Git Source (opens in a new tab)

Inherits: IGatewayZEVM, Initializable, AccessControlUpgradeable, UUPSUpgradeable, ReentrancyGuardUpgradeable, PausableUpgradeable

The GatewayZEVM contract is the endpoint to call smart contracts on omnichain.

The contract doesn't hold any funds and should never have active allowances.

FUNGIBLE_MODULE_ADDRESS

The constant address of the Fungible module.

address public constant FUNGIBLE_MODULE_ADDRESS = 0x735b14BB79463307AAcBED86DAf3322B1e6226aB;

zetaToken

The address of the Zeta token.

address public zetaToken;

PAUSER_ROLE

New role identifier for pauser role.

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");

onlyFungible

Only Fungible module address allowed modifier.

modifier onlyFungible();

constructor

constructor();

initialize

Initialize with address of zeta token and admin account set as DEFAULT_ADMIN_ROLE.

Using admin to authorize upgrades and pause.

function initialize(address zetaToken_, address admin_) public initializer;

_authorizeUpgrade

Authorizes the upgrade of the contract.

function _authorizeUpgrade(address newImplementation) internal override onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
newImplementationaddressThe address of the new implementation.

receive

Receive function to receive ZETA from WETH9.withdraw().

receive() external payable whenNotPaused;

pause

Pause contract.

function pause() external onlyRole(PAUSER_ROLE);

unpause

Unpause contract.

function unpause() external onlyRole(PAUSER_ROLE);

_withdrawZRC20

Internal function to withdraw ZRC20 tokens.

function _withdrawZRC20(uint256 amount, address zrc20) internal returns (uint256);

Parameters

NameTypeDescription
amountuint256The amount of tokens to withdraw.
zrc20addressThe address of the ZRC20 token.

Returns

NameTypeDescription
<none>uint256The gas fee for the withdrawal.

_withdrawZRC20WithGasLimit

Internal function to withdraw ZRC20 tokens with gas limit.

function _withdrawZRC20WithGasLimit(uint256 amount, address zrc20, uint256 gasLimit) internal returns (uint256);

Parameters

NameTypeDescription
amountuint256The amount of tokens to withdraw.
zrc20addressThe address of the ZRC20 token.
gasLimituint256Gas limit.

Returns

NameTypeDescription
<none>uint256The gas fee for the withdrawal.

_transferZETA

Internal function to transfer ZETA tokens.

function _transferZETA(uint256 amount, address to) internal;

Parameters

NameTypeDescription
amountuint256The amount of tokens to transfer.
toaddressThe address to transfer the tokens to.

withdraw

Withdraw ZRC20 tokens to an external chain.

function withdraw(
    bytes memory receiver,
    uint256 amount,
    address zrc20,
    RevertOptions calldata revertOptions
)
    external
    nonReentrant
    whenNotPaused;

Parameters

NameTypeDescription
receiverbytesThe receiver address on the external chain.
amountuint256The amount of tokens to withdraw.
zrc20addressThe address of the ZRC20 token.
revertOptionsRevertOptionsRevert options.

withdrawAndCall

Withdraw ZRC20 tokens and call a smart contract on an external chain.

function withdrawAndCall(
    bytes memory receiver,
    uint256 amount,
    address zrc20,
    bytes calldata message,
    uint256 gasLimit,
    RevertOptions calldata revertOptions
)
    external
    nonReentrant
    whenNotPaused;

Parameters

NameTypeDescription
receiverbytesThe receiver address on the external chain.
amountuint256The amount of tokens to withdraw.
zrc20addressThe address of the ZRC20 token.
messagebytesThe calldata to pass to the contract call.
gasLimituint256Gas limit.
revertOptionsRevertOptionsRevert options.

withdraw

Withdraw ZETA tokens to an external chain.

function withdraw(
    bytes memory receiver,
    uint256 amount,
    uint256 chainId,
    RevertOptions calldata revertOptions
)
    external
    nonReentrant
    whenNotPaused;

Parameters

NameTypeDescription
receiverbytesThe receiver address on the external chain.
amountuint256The amount of tokens to withdraw.
chainIduint256
revertOptionsRevertOptionsRevert options.

withdrawAndCall

Withdraw ZETA tokens and call a smart contract on an external chain.

function withdrawAndCall(
    bytes memory receiver,
    uint256 amount,
    uint256 chainId,
    bytes calldata message,
    RevertOptions calldata revertOptions
)
    external
    nonReentrant
    whenNotPaused;

Parameters

NameTypeDescription
receiverbytesThe receiver address on the external chain.
amountuint256The amount of tokens to withdraw.
chainIduint256Chain id of the external chain.
messagebytesThe calldata to pass to the contract call.
revertOptionsRevertOptionsRevert options.

call

Call a smart contract on an external chain without asset transfer.

function call(
    bytes memory receiver,
    address zrc20,
    bytes calldata message,
    uint256 gasLimit,
    RevertOptions calldata revertOptions
)
    external
    nonReentrant
    whenNotPaused;

Parameters

NameTypeDescription
receiverbytesThe receiver address on the external chain.
zrc20addressAddress of zrc20 to pay fees.
messagebytesThe calldata to pass to the contract call.
gasLimituint256Gas limit.
revertOptionsRevertOptionsRevert options.

deposit

Deposit foreign coins into ZRC20.

function deposit(address zrc20, uint256 amount, address target) external onlyFungible whenNotPaused;

Parameters

NameTypeDescription
zrc20addressThe address of the ZRC20 token.
amountuint256The amount of tokens to deposit.
targetaddressThe target address to receive the deposited tokens.

execute

Execute a user-specified contract on ZEVM.

function execute(
    zContext calldata context,
    address zrc20,
    uint256 amount,
    address target,
    bytes calldata message
)
    external
    onlyFungible
    whenNotPaused;

Parameters

NameTypeDescription
contextzContextThe context of the cross-chain call.
zrc20addressThe address of the ZRC20 token.
amountuint256The amount of tokens to transfer.
targetaddressThe target contract to call.
messagebytesThe calldata to pass to the contract call.

depositAndCall

Deposit foreign coins into ZRC20 and call a user-specified contract on ZEVM.

function depositAndCall(
    zContext calldata context,
    address zrc20,
    uint256 amount,
    address target,
    bytes calldata message
)
    external
    onlyFungible
    whenNotPaused;

Parameters

NameTypeDescription
contextzContextThe context of the cross-chain call.
zrc20addressThe address of the ZRC20 token.
amountuint256The amount of tokens to transfer.
targetaddressThe target contract to call.
messagebytesThe calldata to pass to the contract call.

depositAndCall

Deposit ZETA and call a user-specified contract on ZEVM.

function depositAndCall(
    zContext calldata context,
    uint256 amount,
    address target,
    bytes calldata message
)
    external
    onlyFungible
    whenNotPaused;

Parameters

NameTypeDescription
contextzContextThe context of the cross-chain call.
amountuint256The amount of tokens to transfer.
targetaddressThe target contract to call.
messagebytesThe calldata to pass to the contract call.

executeRevert

Revert a user-specified contract on ZEVM.

function executeRevert(address target, RevertContext calldata revertContext) external onlyFungible whenNotPaused;

Parameters

NameTypeDescription
targetaddressThe target contract to call.
revertContextRevertContextRevert context to pass to onRevert.

depositAndRevert

Deposit foreign coins into ZRC20 and revert a user-specified contract on ZEVM.

function depositAndRevert(
    address zrc20,
    uint256 amount,
    address target,
    RevertContext calldata revertContext
)
    external
    onlyFungible
    whenNotPaused;

Parameters

NameTypeDescription
zrc20addressThe address of the ZRC20 token.
amountuint256The amount of tokens to revert.
targetaddressThe target contract to call.
revertContextRevertContextRevert context to pass to onRevert.

ZeroAddress

Error indicating a zero address was provided.

error ZeroAddress();