You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To provide a new opcode, which returns the type of the address.
Abstract
This TIP specifies a new opcode, which determines whether the address type is a contract address.
Motivation
Some contracts need to limit its callers, such as some functions can only be called by the user, not by the contract.
Specification
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.
Backwards Compatibility
There are no backwards compatibility concerns.
Test Cases
The ISCONTRACT of a contract address is true.
The ISCONTRACT of an account address is false.
The ISCONTRACT of a non-existent address is false.
The ISCONTRACT of a precompiled contract is false.
The ISCONTRACT of self address in constructor function is true.
The ISCONTRACT of a selfdestructed contract address is false.
The text was updated successfully, but these errors were encountered:
Simple Summary
To provide a new opcode, which returns the type of the address.
Abstract
This TIP specifies a new opcode, which determines whether the address type is a contract address.
Motivation
Some contracts need to limit its callers, such as some functions can only be called by the user, not by the contract.
Specification
A new opcode,
ISCONTRACT
, is introduced, with number 0xD4. TheISCONTRACT
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:
The energy cost of the
ISCONTRACT
is 400.Backwards Compatibility
There are no backwards compatibility concerns.
Test Cases
ISCONTRACT
of a contract address istrue
.ISCONTRACT
of an account address isfalse
.ISCONTRACT
of a non-existent address isfalse
.ISCONTRACT
of a precompiled contract isfalse
.ISCONTRACT
of self address in constructor function istrue
.ISCONTRACT
of a selfdestructed contract address isfalse
.The text was updated successfully, but these errors were encountered: