Remove Address.isContract (#3945)
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com> Co-authored-by: Francisco Giordano <fg@frang.io>
This commit is contained in:
@ -19,3 +19,5 @@
|
||||
* xref:crosschain.adoc[Crosschain]
|
||||
|
||||
* xref:utilities.adoc[Utilities]
|
||||
|
||||
* xref:fag.adoc[FAQ]
|
||||
|
||||
13
docs/modules/ROOT/pages/faq.adoc
Normal file
13
docs/modules/ROOT/pages/faq.adoc
Normal file
@ -0,0 +1,13 @@
|
||||
= Frequently Asked Questions
|
||||
|
||||
== Can I restrict a function to EOAs only?
|
||||
|
||||
When calling external addresses from your contract it is unsafe to assume that an address is an externally-owned account (EOA) and not a contract. Attempting to prevent calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract constructor.
|
||||
|
||||
Although checking that the address has code, `address.code.length > 0`, may seem to differentiate contracts from EOAs, it can only say that an address is currently a contract, and its negation (that an address is not currently a contract) does not imply that the address is an EOA. Some counterexamples are:
|
||||
|
||||
- address of a contract in construction
|
||||
- address where a contract will be created
|
||||
- address where a contract lived, but was destroyed
|
||||
|
||||
Furthermore, an address will be considered a contract within the same transaction where it is scheduled for destruction by `SELFDESTRUCT`, which only has an effect at the end of the entire transaction.
|
||||
@ -99,8 +99,6 @@ If you need support for more powerful collections than Solidity's native arrays
|
||||
[[misc]]
|
||||
== Misc
|
||||
|
||||
Want to check if an address is a contract? Use xref:api:utils.adoc#Address[`Address`] and xref:api:utils.adoc#Address-isContract-address-[`Address.isContract()`].
|
||||
|
||||
Want to keep track of some numbers that increment by 1 every time you want another one? Check out xref:api:utils.adoc#Counters[`Counters`]. This is useful for lots of things, like creating incremental identifiers, as shown on the xref:erc721.adoc[ERC721 guide].
|
||||
|
||||
=== Base64
|
||||
|
||||
Reference in New Issue
Block a user