24.this
this 关键字¶
Solidity 中 this
代表合约对象本身;
- 可以通过
address(this)
获取合约地址。 - 可以通过
this.fnName
获取external
函数
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
contract Demo {
function contractAds() external view returns (address) {
return address(this);
}
function testExternal() external view returns (address) {
return this.contractAds();
}
}