{"id":7136,"date":"2024-02-02T08:47:55","date_gmt":"2024-02-02T08:47:55","guid":{"rendered":"https:\/\/metaschool.so\/articles\/?p=7136"},"modified":"2025-01-13T08:03:02","modified_gmt":"2025-01-13T08:03:02","slug":"ethereum-address-contract-vs-eoa","status":"publish","type":"post","link":"https:\/\/metaschool.so\/articles\/ethereum-address-contract-vs-eoa\/","title":{"rendered":"How to Find Out if an Ethereum Address Is a Contract?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_56_1 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/metaschool.so\/articles\/ethereum-address-contract-vs-eoa\/#Using_Etherscan_to_look_for_Ethereum_address\" title=\"Using Etherscan to look for Ethereum address\">Using Etherscan to look for Ethereum address<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/metaschool.so\/articles\/ethereum-address-contract-vs-eoa\/#Using_the_Code_Size_of_the_Address\" title=\"Using the Code Size of the Address\">Using the Code Size of the Address<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/metaschool.so\/articles\/ethereum-address-contract-vs-eoa\/#Conclusion\" title=\"Conclusion\">Conclusion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/metaschool.so\/articles\/ethereum-address-contract-vs-eoa\/#FAQs\" title=\"FAQs\">FAQs<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>Knowing whether an Ethereum address is a smart contract address or an externally owned account (EOA) address can be important for a lot of reasons. Let&#8217;s discuss a few reasons why:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Transaction Behavior<\/strong>: A smart contract can be programmed in a way that whenever it receives a transaction, it triggers an automated action. In contrast, EOAs are controlled by private keys and do not have such automated behaviors. So knowing the type of the Ethereum address can help anticipate the outcome of any transactions or other interactions.<\/li>\n\n\n\n<li><strong>Security Considerations<\/strong>: Interacting with unknown smart contracts can pose severe security risks (and is definitely not recommended), as they may contain malicious code. Identifying an Ethereum address as a contract allows for due diligence, such as reviewing the contract&#8217;s code and verifying its authenticity before engagement.<\/li>\n\n\n\n<li><strong>Functionality and Compatibility<\/strong>: Some operations or applications may be designed to interact specifically with either contracts or EOAs. For example, sending tokens to a contract that isn&#8217;t designed to handle them could result in a loss of funds. Understanding the address type ensures compatibility and prevents errors.<\/li>\n\n\n\n<li><strong>Gas Optimization<\/strong>: Transactions that involve smart contracts may require more computational resources which may lead to a higher <a href=\"https:\/\/metaschool.so\/articles\/gwei-meaning\">gas fees<\/a>. By identifying the address type, users can estimate transaction costs more accurately and avoid losing their money unintentionally.<\/li>\n<\/ul>\n\n\n\n<p>Now that we know why it&#8217;s important to be informed about what an Ethereum address may be tied to, we will be going through two methods that you can use to determine whether the address is a smart contract address or an EOA address.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-etherscan-to-look-for-ethereum-address-1\"><span class=\"ez-toc-section\" id=\"Using_Etherscan_to_look_for_Ethereum_address\"><\/span>Using Etherscan to look for Ethereum address<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In Ethereum, the easiest way to determine whether an address is a contract is by going to Etherscan and pasting the address.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Go to Etherscan<\/strong>: Navigate to the Etherscan <a href=\"https:\/\/etherscan.io\/\" target=\"_blank\" rel=\"noopener\">website<\/a>.<\/li>\n\n\n\n<li><strong>Search for the Address<\/strong>: In the search bar, enter the Ethereum contract address you want to check. And then click on search.<\/li>\n\n\n\n<li><strong>View Address Information<\/strong>: Once you&#8217;ve searched for the address, you&#8217;ll be taken to the address&#8217;s details page on Etherscan. This page will show you information related to the address you have entered which is publicly available for everyone to view.<\/li>\n\n\n\n<li><strong>Check the &#8216;Contract&#8217; Section<\/strong>: If the address is a contract, on the address details page, there should be a section labeled &#8220;Contract&#8221; or &#8220;Contract Information.&#8221; If the address is a contract, this section will display details about the contract, such as its bytecode, creation transaction, entire code of the contract if it has been verified and some other information related to the contract.<\/li>\n\n\n\n<li><strong>EOA vs. Contract<\/strong>: If the address is an EOA and not a contract, the &#8220;Contract&#8221; section will not appear, and you&#8217;ll mostly see transaction history, balance, and other details associated with an Ethereum address. EOA simply refers to regular Ethereum address owned by an entity and are controlled by private key.<\/li>\n<\/ol>\n\n\n\n<p><strong>\ud83d\udd25 Check this out:<\/strong>&nbsp;<a href=\"https:\/\/metaschool.so\/courses\/build-in-public\" target=\"_blank\" rel=\"noreferrer noopener\">Build in Public<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"using-code-size-of-the-address-1\"><span class=\"ez-toc-section\" id=\"Using_the_Code_Size_of_the_Address\"><\/span>Using the Code Size of the Address<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Another way you can determine whether a given address is a contract or an EOA by checking the code size of the address. If an address is a contract, its code size will be greater than zero, as contracts have bytecodes associated with them, whereas EOAs do not.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#1E1E1E\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"pragma solidity ^0.8.0;\n\ncontract AddressChecker {\n    function isContract(address _address) public view returns (bool) {\n        uint256 codeSize;\n        assembly {\n            codeSize := extcodesize(_address)\n        }\n        return codeSize &gt; 0;\n    }\n}\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #C586C0\">pragma<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">solidity<\/span><span style=\"color: #D4D4D4\"> ^0.8.0;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">contract<\/span><span style=\"color: #4EC9B0\"> AddressChecker<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">function<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #DCDCAA\">isContract<\/span><span style=\"color: #D4D4D4\">(<\/span><span style=\"color: #4EC9B0\">address<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #9CDCFE\">_address<\/span><span style=\"color: #D4D4D4\">) <\/span><span style=\"color: #569CD6\">public<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">view<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #C586C0\">returns<\/span><span style=\"color: #D4D4D4\"> (<\/span><span style=\"color: #4EC9B0\">bool<\/span><span style=\"color: #D4D4D4\">) {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #4EC9B0\">uint256<\/span><span style=\"color: #D4D4D4\"> codeSize;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">assembly<\/span><span style=\"color: #D4D4D4\"> {<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">            codeSize := <\/span><span style=\"color: #DCDCAA\">extcodesize<\/span><span style=\"color: #D4D4D4\">(_address)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #C586C0\">return<\/span><span style=\"color: #D4D4D4\"> codeSize &gt; <\/span><span style=\"color: #B5CEA8\">0<\/span><span style=\"color: #D4D4D4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">}<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In this contract, the <strong><code>isContract<\/code><\/strong> function takes an Ethereum address as an argument and returns <strong><code>true<\/code><\/strong> if the address is a contract and <strong><code>false<\/code><\/strong> if it&#8217;s an EOA.<\/p>\n\n\n\n<p><strong>\ud83d\udd25 Check this out:<\/strong>&nbsp;<a href=\"https:\/\/metaschool.so\/courses\/writing-your-first-hello-world-contract-in-solidity\" target=\"_blank\" rel=\"noreferrer noopener\">Write Your First Solidity Smart Contract on Ethereum<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Understanding whether an Ethereum address is a smart contract address or an EOA address is important to ensure secure and efficient blockchain interactions. This knowledge enables users to anticipate transaction behaviors, assess security implications, ensure compatibility, and optimize transaction costs. If you can successfully identify the nature of an address, you can make informed decisions and potentially save yourself from making a costly mistake (literally).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQs<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1736755211420\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">What is the difference between an Externally Owned Account (EOA) and a Smart Contract Account?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>An Externally Owned Account (EOA) is controlled by a private key and is typically used by individuals to manage their Ether and initiate transactions. In contrast, a smart contract account is governed by code deployed on the Ethereum network, operating autonomously based on predefined rules without requiring a private key. <a href=\"https:\/\/ethereum.org\/en\/developers\/docs\/accounts\/?utm_source=chatgpt.com\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1736755252614\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">How can I determine if an Ethereum address is an EOA or a smart contract?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>To identify the type of an Ethereum address, you can use blockchain explorers like Etherscan. By entering the address into the search bar, you can view its details. If the address is a contract, there will be a &#8220;Contract&#8221; section displaying information such as the contract&#8217;s bytecode and creation transaction. Additionally, in Solidity, you can check the code size of an address; contracts have associated bytecode, resulting in a code size greater than zero, whereas EOAs have a code size of zero.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1736755278955\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \">Why is it important to know whether an Ethereum address is an EOA or a smart contract?<\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Understanding whether an Ethereum address is an EOA or a smart contract is essential for:<br \/><strong>Transaction Behavior<\/strong>: Smart contracts trigger automated actions, unlike EOAs, which rely on private keys.<br \/><strong>Security<\/strong>: Unknown contracts may carry malicious code.<br \/><strong>Compatibility<\/strong>: Some operations are tailored for contracts or EOAs.<br \/><strong>Gas Fees<\/strong>: Smart contract interactions often incur higher gas costs.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"","protected":false},"author":17,"featured_media":11068,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[292],"tags":[51,31,74,68],"class_list":["post-7136","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-answers","tag-blockchain","tag-ethereum-blockchain","tag-web3-glossary","tag-web3-words"],"_links":{"self":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/7136","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/comments?post=7136"}],"version-history":[{"count":24,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/7136\/revisions"}],"predecessor-version":[{"id":11814,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/7136\/revisions\/11814"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media\/11068"}],"wp:attachment":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media?parent=7136"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/categories?post=7136"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/tags?post=7136"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}