抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

1. ERC173简介

​ 该协议定义了拥有或控制合约的标准功能。

2. ERC173的工作原理

ERC-173还要求合约同时还应该实现ERC165接口。

接口如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
interface ERC173 /* is ERC165 */ {
/// @dev This emits when ownership of a contract changes.
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

/// @notice Get the address of the owner
/// @return The address of the owner.

function owner() view external returns(address);

/// @notice Set the address of the new owner of the contract
/// @dev Set _newOwner to address(0) to renounce any ownership.
/// @param _newOwner The address of the new owner of the contract

function transferOwnership(address _newOwner) external;
}

​ 查询当前合约的owner,以及转让当前合约的所有权。

注:如果执行转移所有权操作的时候,应该注意_newOwner的值不能为零地址,如果将合约转移给了零地址,那么该合约将不属于任何人。

3. 与Ownable.sol的区别

Ownable.sol是基于ERC173的理念拓展完善的,丰富了关于owner的相关操作,比如对owner的检查,还有对不能将还有转让给零地址;同时也加入了一些访问控制,让transferOwnership函数更安全。

评论



政策 · 统计 | 本站使用 Volantis 主题设计