Skip to main content
Version: Endpoint V2 Docs

Transfer Ownership

All of LayerZero’s Contract Standards, by default, inherit the OpenZeppelin Ownable Standard. This means that when you deploy any LayerZero contract (such as OApp or OFT), you can set the deployer as the initial owner of the contract.

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.22;
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
import { OFT } from "@layerzerolabs/oft-evm/contracts/OFT.sol";

contract MyOFT is OFT {
constructor(
string memory _name,
string memory _symbol,
address _lzEndpoint,
address _delegate
) OFT(_name, _symbol, _lzEndpoint, _delegate) Ownable(_delegate) {}
}
tx = await(await oft.transferOwnership(newAddress)).wait();

This setup allows you to maintain control over the contract after deployment, with the flexibility to transfer ownership to any other address when needed. This ownership mechanism ensures secure and manageable contract administration.