tip: 44
title: TRC-44 Address.isContract instructions
author: llwslc<llwslc@gmail.com>
discussions to: https://github.com/tronprotocol/TIPs/issues/44
category: TRC
status: Final
created: 2019-07-10
To provide a new opcode, which returns the type of the address.
This TIP specifies a new opcode, which determines whether the address type is a contract address.
Some contracts need to limit its callers, such as some functions can only be called by the user, not by the contract.
A new opcode, ISCONTRACT, is introduced, with number 0xD4. The ISCONTRACT takes one argument from the stack, pushes to the stack the boolean value whether the address type is a contract address.
In case the address does not exist false is pushed to the stack.
example:
contract Test {
function checkAddr(address addr) view public returns (bool) {
return addr.isContract;
}
}
The energy cost of the ISCONTRACT is 400.
There are no backwards compatibility concerns.
- The
ISCONTRACTof a contract address istrue. - The
ISCONTRACTof an account address isfalse. - The
ISCONTRACTof a non-existent address isfalse. - The
ISCONTRACTof a precompiled contract isfalse. - The
ISCONTRACTof self address in constructor function istrue. - The
ISCONTRACTof a selfdestructed contract address isfalse.