Skip to Content
Mastering Blockchain Programming with Solidity
book

Mastering Blockchain Programming with Solidity

by Jitendra Chittoda
August 2019
Intermediate to advanced
486 pages
13h 52m
English
Packt Publishing
Content preview from Mastering Blockchain Programming with Solidity

Check for contracts using Address.sol

In your contract, when you need to confirm whether an address is a contract or an EOA, you can use the Address.sol library. This library provides a function, isContract(), which checks the address and finds the byte size of the contract attached to that address. If the code size is greater than zero, that means it is a contract.

However, this is not the recommended way to check whether an address is a contract or not. During the contract's constructor execution, a contract isn't treated as a contract. Thus, if you call the isContract() function while a contract is executing its constructor, then the function would return false.

The OpenZeppelin contract present at Chapter09/openzeppelin-solidity/contracts/utils/Address.sol ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood
Complete Cryptocurrency and Blockchain Course | Learn Solidity

Complete Cryptocurrency and Blockchain Course | Learn Solidity

Ravinder Deol, Codestars By Rob Percival, Thomas Wiesner

Publisher Resources

ISBN: 9781839218262Supplemental Content