Build
Architecture
protocol
contracts
evm
ZetaConnectorBase.sol
Abstract.zetaconnectorbase

Git Source (opens in a new tab)

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

Abstract base contract for ZetaConnector.

This contract implements basic functionality for handling tokens and interacting with the Gateway contract.

gateway

The Gateway contract used for executing cross-chain calls.

IGatewayEVM public gateway;

zetaToken

The address of the Zeta token.

address public zetaToken;

tssAddress

The address of the TSS (Threshold Signature Scheme) contract.

address public tssAddress;

WITHDRAWER_ROLE

New role identifier for withdrawer role.

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

PAUSER_ROLE

New role identifier for pauser role.

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

TSS_ROLE

New role identifier for tss role.

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

initialize

Initializer for ZetaConnectors.

Set admin as default admin and pauser, and tssAddress as tss role.

function initialize(
    address gateway_,
    address zetaToken_,
    address tssAddress_,
    address admin_
)
    public
    virtual
    initializer;

_authorizeUpgrade

Authorizes the upgrade of the contract, sender must be owner.

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

Parameters

NameTypeDescription
newImplementationaddressAddress of the new implementation.

updateTSSAddress

Update tss address

function updateTSSAddress(address newTSSAddress) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
newTSSAddressaddressnew tss address

pause

Pause contract.

function pause() external onlyRole(PAUSER_ROLE);

unpause

Unpause contract.

function unpause() external onlyRole(PAUSER_ROLE);

withdraw

Withdraw tokens to a specified address.

function withdraw(address to, uint256 amount, bytes32 internalSendHash) external virtual;

Parameters

NameTypeDescription
toaddressThe address to withdraw tokens to.
amountuint256The amount of tokens to withdraw.
internalSendHashbytes32A hash used for internal tracking of the transaction.

withdrawAndCall

Withdraw tokens and call a contract through Gateway.

function withdrawAndCall(
    MessageContext calldata messageContext,
    address to,
    uint256 amount,
    bytes calldata data,
    bytes32 internalSendHash
)
    external
    virtual;

Parameters

NameTypeDescription
messageContextMessageContextMessage context containing sender.
toaddressThe address to withdraw tokens to.
amountuint256The amount of tokens to withdraw.
databytesThe calldata to pass to the contract call.
internalSendHashbytes32A hash used for internal tracking of the transaction.

withdrawAndRevert

Withdraw tokens and call a contract with a revert callback through Gateway.

function withdrawAndRevert(
    address to,
    uint256 amount,
    bytes calldata data,
    bytes32 internalSendHash,
    RevertContext calldata revertContext
)
    external
    virtual;

Parameters

NameTypeDescription
toaddressThe address to withdraw tokens to.
amountuint256The amount of tokens to withdraw.
databytesThe calldata to pass to the contract call.
internalSendHashbytes32A hash used for internal tracking of the transaction.
revertContextRevertContextRevert context to pass to onRevert.

receiveTokens

Handle received tokens.

function receiveTokens(uint256 amount) external virtual;

Parameters

NameTypeDescription
amountuint256The amount of tokens received.

ZeroAddress

Error indicating that a zero address was provided.

error ZeroAddress();