Skip to main content

OApp

OApp

Abstract contract serving as the base for OApp implementation, combining OAppSender and OAppReceiver functionality.

Methods

allowInitializePath

function allowInitializePath(Origin origin) external view returns (bool)

Parameters

NameTypeDescription
originOriginundefined

Returns

NameTypeDescription
_0boolundefined

endpoint

function endpoint() external view returns (contract ILayerZeroEndpointV2)

Retrieves the LayerZero endpoint associated with the OApp.

Returns

NameTypeDescription
_0contract ILayerZeroEndpointV2undefined

isComposeMsgSender

function isComposeMsgSender(Origin, bytes, address _sender) external view returns (bool)

Parameters

NameTypeDescription
_0Originundefined
_1bytesundefined
_senderaddressundefined

Returns

NameTypeDescription
_0boolundefined

lzReceive

function lzReceive(Origin _origin, bytes32 _guid, bytes _message, address _executor, bytes _extraData) external payable

Parameters

NameTypeDescription
_originOriginundefined
_guidbytes32undefined
_messagebytesundefined
_executoraddressundefined
_extraDatabytesundefined

nextNonce

function nextNonce(uint32, bytes32) external view returns (uint64 nonce)

Retrieves the next nonce for a given source endpoint and sender address.

_srcEid The source endpoint ID._sender The sender address.The path nonce starts from 1. If 0 is returned it means that there is NO nonce ordered enforcement.Is required by the off-chain executor to determine the OApp expects msg execution is ordered.This is also enforced by the OApp.By default this is NOT enabled. ie. nextNonce is hardcoded to return 0.

Parameters

NameTypeDescription
_0uint32undefined
_1bytes32undefined

Returns

NameTypeDescription
nonceuint64The next nonce.

oAppVersion

function oAppVersion() external pure returns (uint64 senderVersion, uint64 receiverVersion)

Retrieves the OApp version information.

Returns

NameTypeDescription
senderVersionuint64The version of the OAppSender.sol implementation.
receiverVersionuint64The version of the OAppReceiver.sol implementation.

owner

function owner() external view returns (address)

Returns the address of the current owner.

Returns

NameTypeDescription
_0addressundefined

peers

function peers(uint32 eid) external view returns (bytes32 peer)

Retrieves the peer (OApp) associated with a corresponding endpoint.

Parameters

NameTypeDescription
eiduint32undefined

Returns

NameTypeDescription
peerbytes32undefined

renounceOwnership

function renounceOwnership() external nonpayable

Leaves the contract without owner. It will not be possible to call onlyOwner functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.

setDelegate

function setDelegate(address _delegate) external nonpayable

Sets the delegate address for the OApp.

Only the owner/admin of the OApp can call this function.Provides the ability for a delegate to set configs, on behalf of the OApp, directly on the Endpoint contract.

Parameters

NameTypeDescription
_delegateaddressThe address of the delegate to be set.

setPeer

function setPeer(uint32 _eid, bytes32 _peer) external nonpayable

Sets the peer address (OApp instance) for a corresponding endpoint.

Only the owner/admin of the OApp can call this function.Indicates that the peer is trusted to send LayerZero messages to this OApp.Set this to bytes32(0) to remove the peer address.Peer is a bytes32 to accommodate non-evm chains.

Parameters

NameTypeDescription
_eiduint32The endpoint ID.
_peerbytes32The address of the peer to be associated with the corresponding endpoint.

transferOwnership

function transferOwnership(address newOwner) external nonpayable

Transfers ownership of the contract to a new account (newOwner). Can only be called by the current owner.

Parameters

NameTypeDescription
newOwneraddressundefined

Events

OwnershipTransferred

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner)

Parameters

NameTypeDescription
previousOwner indexedaddressundefined
newOwner indexedaddressundefined

PeerSet

event PeerSet(uint32 eid, bytes32 peer)

Parameters

NameTypeDescription
eiduint32undefined
peerbytes32undefined

Errors

InvalidDelegate

error InvalidDelegate()

InvalidEndpointCall

error InvalidEndpointCall()

LzTokenUnavailable

error LzTokenUnavailable()

NoPeer

error NoPeer(uint32 eid)

Parameters

NameTypeDescription
eiduint32undefined

NotEnoughNative

error NotEnoughNative(uint256 msgValue)

Parameters

NameTypeDescription
msgValueuint256undefined

OnlyEndpoint

error OnlyEndpoint(address addr)

Parameters

NameTypeDescription
addraddressundefined

OnlyPeer

error OnlyPeer(uint32 eid, bytes32 sender)

Parameters

NameTypeDescription
eiduint32undefined
senderbytes32undefined