Much of the beauty of Web3 lies in its ability to facilitate permissionless and trustless transactions without the intervention of any third-party intermediary or centralized authority. But how does this magic really happen? Dubbed “Internet Legos” by Packy McCormick, smart contracts are widely considered to be the building blocks of Web3.
A smart contract is a computer program that lives on the blockchain. It is governed by rudimentary “if/when…then” statements. For example, “if ‘a’ happens, then execute step ‘b.’” Once these predetermined terms are met, the transaction automatically executes and is recorded in the blockchain.
Composable by nature, these computer programs can be strung together to build full-fledged decentralized applications that plug directly into the blockchain. From blue-chip NFTs and decentralized finance protocols, to DAOs that aim to buy the U.S, Constitution, all of these Web3 projects are powered by smart contracts.
For NFTs specifically, smart contracts are used to execute events around minting and burning tokens, facilitating transactions, and distributing royalties. Under the hood, a token’s smart contract contains a trove of important data around the distribution, function, and transaction volume of a token. Not only is this information valuable for evaluating the health of a project, but it can also make you a safer and more knowledgeable NFT enthusiast.
Surprisingly, you don’t need a programming background to glean valuable information from a smart contract, but you do need to know where to look. And that’s exactly what we’re here for.
How to access an NFT’s smart contract
The best way to view a token’s smart contract is through Etherscan, a block explorer and analytics platform built on Ethereum. Block explorers like Etherscan allow users to search and index real-time and historical information about a blockchain. Here, users can easily access any relevant information about specific tokens, smart contracts, transactions, or individual wallets.
To access a token’s smart contract, most users take one of two routes: Etherscan search or via an NFT marketplace listing.
Featured prominently on Etherscan’s homepage is a large search bar. Here, users can query the blockchain by wallet address, transaction hash, block number, token name, or Ethereum Name Service (ENS) address.
For the sake of this article, we will search by token name. Let’s use CryptoPunks as an example.
While this may be the quickest method, it also leaves the largest room for error and bad actors. Remember, this search spans the entire blockchain. Therefore, you may receive results for scam or inauthentic tokens with similar names to your initial search query. While these are harmless to view and explore, the contract itself could be harmful to interact with. Also, if you are searching for a specific data point, it will be inaccurate.
As shown above, our search returns multiple results for CryptoPunks, but only the first collection is marked with the blue verified checkmark, indicating that this is the verified CryptoPunks collection. This will take you to the collection’s token page.
On the token page, navigate to the profile summary card on the right-hand side. As a second line of defense, always be sure to verify the authenticity of the collection through the profile summary panel. This should feature the official collection site and social profiles, including an OpenSea page.
Click the link next to contract, which will direct you to the token’s smart contract (circled in the image below).
Via NFT marketplace listing
The longer (but safer) route toaccess a token’s smart contract is via a CryptoPunk’s token listing on an NFT marketplace. On marketplaces like LooksRare and OpenSea, the contract address is linked within the details/ properties card, which lives on the left side of the NFT listing.
While marketplaces like Rarible and Foundation don’t link to the contract directly, they do link to the mint transaction where the contract address can be quickly found. In the example below, we see the contract link for the Magnum Photos 75 Collection listed on Foundation.
The main contract page
The main contract page acts as the homepage of the contract. Within the contract overview and more info sections, users can find the total balance of ETH the contract holds and its respective value in USD. The more info section also includes a link to the initial mint transaction and the wallet used for the primary mint.
Scrolling deeper into the page and its respective tabs reveals a trove of information about transactions, holders, analytics, and the code of the contract itself. Let’s dig a bit further.
The transactions tab shows a chronological list of all blockchain transactions, including timestamps, the wallet addresses associated with each transaction, the value of the transaction, and the respective gas fee.
The Txn Hash column enables users to dive deeper into the details of a specific blockchain transaction. This is followed by the method column which describes the function executed in the transaction. Examples can include sale, mint, transfer, and approval setting. In this example, the functions listed are: withdraw bid, enter bid, and withdraw.
The contracts tab is divided into three sections: code, read contract, and write contract. Before continuing, it’s always important to confirm that the contract you want to read has been verified. This ensures that the contract code provided to Etherscan by the owner of the contract matches the contract that lives on the Ethereum blockchain. As you can see in the image below, this contract is verified which means you’re safe to proceed.
As suggested by its name, the code tab reveals the smart contract’s source code. Unless you have the technical skills to read the Solidity programming language, this may seem undecipherable. However, there are usually comments that separate each section of the code and identify its associated function.
For the curious, this could be a good way to learn the basic functions of Solidity.
The read code tab displays information that is generally not featured on the front page of the main contract page. While this information may vary depending on the contract, this tab generally gives users the ability to query the various smart contract functions for specific information.
For example, the balanceOf section, allows users to verify how many CryptoPunks a single wallet holds, simply by inputting a wallet address.
Let’s try gamer FaZe Bank’s wallet.
Boom. FaZe owns nine CryptoPunks.
By connecting your wallet to Etherscan, permitted users can perform any function written in the smart contract directly from the Etherscan UI. This includes submitting and withdrawing bids, purchasing, and transferring the NFT. This is significantly more difficult and less practical than transacting through an NFT marketplace, but hey, different (key)strokes for different folks.
Also located on the main contract page at the bottom of the more info box is a link for the token tracker.
The token tracker link provides additional insight into the collection itself including the minimum token value, maximum token supply, the total amount of unique wallets holding the token, and the total number of transfers. This information can often be used to signify the strength of an NFT collection and its respective community.
A community with a large number of unique holders and many transfers is often much healthier and more active than a project where a few whales own the majority of the supply and tokens rarely change hands. Furthermore, the transfers tab below provides an immutable record of every transfer of a token in the collection, capturing the date, time, sale price, and wallet addresses of the parties involved.
The holders tab, conveniently located to the right of the transfers tab, provides a full breakdown of who owns the most tokens in the contract. For better visualization, click the token holder’s chart in the top left-hand corner to see the data presented in a pie chart.
As we can see from this example, the top 100 holders collectively own 46.48 percent of CryptoPunks.
Lastly, the analytics tab showcases additional data around transaction count, unique senders, ETH fees, transfers, and more. Ultimately, available data varies by collection. In the CryptoPunks chart below, we are able to sift through data regarding ether balance, transactions, transaction fees, ETH and token transfers, and more.
At this point, you should have a basic understanding of smart contracts and Etherscan. With the entirety of the blockchain at your fingertips, how you choose to use this information is ultimately up to you.