Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article examines ERC-173, which standardizes smart contract ownership and ownership transfer. The original figures are retained and may contain Japanese labels.

This explanation is based on the following specification.

Overview

ERC-173 defines standard functions for owning or controlling a contract.

The interface allows applications to retrieve the current owner address, transfer ownership, and observe a standardized event when ownership changes.

Motivation

Many smart contracts need to be owned or controlled by an address that can perform administrative operations or withdraw funds.

Standardizing the ownership interface improves interoperability between contracts and user interfaces.

Examples of contracts and applications that benefit from standardization include the following.

  1. Exchanges for buying, selling, or auctioning Ethereum contracts.
    • These can identify a contract's owner and transfer its ownership.
  2. Contract wallets that hold and transfer ownership of contracts.
  3. Contract deployment and management systems.
    • It may be appropriate to allow only owners to add or remove their contracts.
    • Such systems may verify a signature from the contract owner.
  4. Interfaces for displaying and transferring contract ownership.

Specification

ERC-173 contracts implement the ERC-173 interface. The original article also describes ERC-165 support for interface discovery.

javascript
interface ERC173 /* is ERC165 */ {
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    function owner() view external returns(address);
	
    function transferOwnership(address _newOwner) external;	
}

interface ERC165 {
    function supportsInterface(bytes4 interfaceID) external view returns (bool);
}

OwnershipTransferred

This event is emitted when contract ownership is transferred. The previous owner and new owner addresses are indexed in the event log.

Ownership transfer event

owner

The owner() function returns the current contract owner's address. It may be implemented as either pure or view.

transferOwnership

The transferOwnership function transfers ownership to another address. Only the owner can execute this operation.

To renounce ownership, pass the zero address, address(0), as _newOwner.

Setting the owner to the zero address means that no ordinary account holds ownership under this scheme.

Transferring or renouncing contract ownership

The function may be implemented as either public or external.

Additional Considerations

The standard emphasizes a minimal interface to avoid unnecessary contract size, backward compatibility, simplicity, and gas efficiency.

The proposal also considers the following alternatives.

  1. Associating an Ethereum Name Service (ENS) domain with a contract.

    • The contract's owner() function can reference the owner of a particular ENS name and use that address as its own owner.
    • Ownership of the contract can then be transferred by transferring the ENS name.
    • Drawbacks include limited backward compatibility and the gas costs of calling external ENS contracts to determine ownership.
  2. Associating an ERC-721 NFT with a contract.

    • Contract ownership can be linked to NFT ownership.
    • Existing ERC-721 infrastructure can be used to buy, sell, or auction contracts.
    • The approach requires additional complexity and infrastructure.
    • An NFT associated with a contract does not automatically track its ownership unless the system is designed to do so.
    • This ownership mechanism is not inherently backward compatible with existing contracts.

ERC-173 does not prevent a contract from implementing these or other ownership schemes alongside the standard interface. A contract can support multiple ways to manage or transfer ownership.

The aim is a lightweight, straightforward, backward-compatible ownership scheme suitable for broad adoption.

Security Considerations

If owner() returns an externally owned account address, its private key must be protected against loss or disclosure.

Backward Compatibility

Many existing contracts already implement this interface.

Conclusion

ERC-173 standardizes the retrieval and transfer of smart contract ownership. Additional implementation examples may be added in the future.