How to Read Smart Contract Data
|— Smart contracts are everywhere in crypto – they were the foundation of DeFi, dApps and NFTs and you will certainly encounter one as you interact – but do you know how to read one?|
— Smart contracts are self-executing digital agreements that allow us to interact with other users and platforms remotely, without a middleman. But they are unambiguous, and once you sign one, it cannot be reversed.
— Lack of understanding about how to read smart contracts is a key vector for scams – so knowing how to read them is an essential competence for anyone operating in the crypto space.
— You can do this by learning how to read information about a smart contract on blockchain explorers such as Ehterscan.
— So, in this article, we delve into what a smart contract is, why gaps in your knowledge can make you vulnerable to scams and how you can read a smart contract to secure yourself against risks.
There are three things you cannot escape: death, taxes, and smart contracts. We aren’t even joking.
No matter what type of transaction you want to make in the decentralized realm, you will likely be using a smart contract to process it. Trading, deposits, withdrawals, staking and even NFTs – no matter what you’re up to, it is likely that a smart contract is helping you do it.
With smart contracts being so central to the space, being able to read their data is an essential skill for anyone using the ecosystem. So, let’s dive in. Here, you’ll find out how to understand smart contracts, learn to read their data, and become a pro on the technical details of crypto interactions.
But First – What is a Smart Contract?
In one sentence, smart contracts are digital contracts coded to take decisions based on a given input and execute any type of transaction between multiple anonymous parties without the need for manual intervention or trust.
So, let’s say you want to take a loan on a DeFi protocol. The smart contract of the protocol will issue you a loan as soon as it can verify that you have locked the required collateral. And when it’s the time for loan repayment, you can simply pay the total amount alongside the interest, and the smart contract will automatically release your collateral. Throughout this process, there will be no manual intervention or legal documentation required in this process.
Smart contracts are pretty amazing because they allow complex transactions to take place without anyone acting as a middleman – but precisely because there is no human element to the process, there is no ambiguity in the process. In other words, no matter what you do, once you agree to a smart contract, it will execute. You cannot call customer service and say you were misled, or reverse the agreement because the project doesn’t seem so hot after all. And this is why it’s absolutely essential to understand what you’re agreeing to.
Smart Contracts: Why Understanding is Key to Security
This tweet from February 13, 2022, provides a great example of why being able to read a smart contract is essential. Here, two scammers imitated the founders of a popular Solana-based game called Space Falcon and gifted the victim two NFTs that he could stake to earn rewards.
The only catch was, it wasn’t the actual Space Falcon, and the smart contract in question would actually allow the scammers to drain 100% of the wallet’s funds once the wallet owner approved the transaction. Luckily, the prospect here conducted due diligence and read the smart contract (thanks to transparency!) to realize that it was in fact a “scam contract”.
You can think of smart contracts as the Ts and Cs of crypto transactions. They go beyond the hype and FOMO to give you precise details about exactly what a project is, who owns it and what you’re agreeing to.
And you don’t need to be a coder to understand most of the info – because you have a tool called Etherscan. Here we explain how it works.
How to Read a Smart Contract Using Etherscan
As we mentioned earlier, smart contracts are everywhere, Ethereum, Avalanche, Solana, Tezos, you name it. However, for the purpose of this article, we will use Ethereum and its de facto blockchain explorer Etherscan to understand how you can read smart contract data.
In the below sections, we will walk you through the process of
1. Finding a smart contract
2. Reading basic details such as creator address, token name, tokens held in the contract and so on.
3. Understanding the statistics of a contract’s tokens and what they convey.
4. Searching and understanding the transactions that have happened through a smart contract.
5. Finding the source code of a contract for deeper analysis.
So, let’s get started.
Let’s start with the basics – you’ll first need to find the smart contract address for the project you’re dealing with. This is basically the central hub for project specifics. This can be found either on a project’s official website, OpenSea page, white paper, GitHub page, Discord, marketplace listing page (for NFTs) or on its CoinMarketCap or CoinGecko page.
Once you have the smart contract address and you’ve copied it, you can go to etherscan.io, paste it into the search bar, and hit enter to go to the smart contract’s page.
Here, you can find out a number of different things. Let’s go through them one by one, and discuss how they can help you assess a project for yourself.
When we talk about contract identity, we’re really talking about the fundamentals of a given protocol; its.creator and creation date, the value locked in the protocol and the native tokens that make it function, all of which will allow you to start building a picture of the project.
You will find these important elements on the first half of this page:
1. Reserve, Value, and Token: They will show you the total ETH held by the contract, its total value at the current price of ETH, and the total value of other assets held in the contract.
2. Creator and Transaction Hash: Here, you will see the wallet address of the creator and the transaction hash of the transaction that you can click on to see more details.
3. Token Tracker: By clicking on it, you will be redirected to a page with all the information about the native token of the smart contract.
If you click on the wallet address of the contract creator, you will be directed to a page that has all the transaction and fund details of the wallet that created the smart contract. You can check this to assess how active the wallet has been and what wallets and contracts it has previously interacted with.
What can you learn from these first details?
A new wallet, no transaction history, a new contract, and such contradicting data may be a reason for you to be vigilant. However, this is just one data point – and you must study the contract further to build a clearer picture.
Token supply and ownership are key questions when it comes to assessing the utility and future of a project. For example, knowing the total token supply (and whether it is capped) will enable you to understand what participation rights you might have in a project if you buy X amount of tokens. It will also help you know your stake in the project and how safe you are against dilution or major dumps that cause prices to plummet.
Similarly, ownership distribution can give you a good indication of the security of a project. The higher the number of holders and the more evenly the tokens are distributed among these holders, the safer and more decentralized the project likely is.
So, if a smart contract has 10 million tokens, but 4 million of those are owned by just one wallet, the project’s future can be heavily impacted by just one player, and that risk needs to be factored into your projections.
So how can we check those things on EthersScan.io?
You can check the details of the native token of a contract by clicking on the Tracker link.
This will take you to a page that displays the price of the token, its fully diluted and circulating supply market capitalization (click to switch between the two), the maximum token supply, total number of wallets that hold the token and the number of transfers that have been made with it.
These details combined can help you understand how popular a token is and how well distributed its supply is among holders.
You can further click on “Holders” in the below section, and it will display the rank of all token holders based on the percentage of the total token supply they hold. The more diversified the supply, the more distributed the project is, and the safer the token is from pump and dump practices.
Another way to build a picture of a project’s legitimacy is by looking at its token transaction history. If a project has processed many transactions using its native token over a long period of time, this supports the notion that the project has been running a while already, has an active user base, and suggests you’ll be able to gain some insight about its activity and success from looking at other metrics.
Conversely, if all the transactions have taken place recently, or predominantly feature the same wallet addresses, you may want to do some more research about the project, since this doesn’t give any real insight into its story, activity or user engagement.
Luckily, this is also something you can check on Etherscan.io.
To do this, you must go back to the main contract page, make sure you’re in the Transactions tab, and scroll down to see all transactions.
You can further click into each of these latest transactions to read their details and actions, which will provide you a summary of what type of transactions people are making through the contract, be this new mints or wallet-to-wallet transactions.
To dig deeper into how well a contract has performed among its users, you can go to the Analytics section and check the graphical representation of the number of transactions using the contract.
Any smart contract with suspicious code will certainly not have many transactions and it may be a clear sign for you to be more cautious with the contract.
Contract Code and Function
OK so we’ve talked about how to investigate a project, but what about the substantive functions of the smart contract? Code is law when it comes to smart contracts, and the coding is what determines what functions a smart contract can handle.
Blockchain has a culture of transparency, and generally speaking the coding for smart contract functions will be published for anyone to review and read. So, if you are into coding, you can check the contract code by clicking on “Contract” in the same tab where you checked the contract transactions. This visibility into the code will allow you to assess if the contract is legit or if it’s trying to siphon funds from its users.
Where a protocol does not publish their source codes for public review, it’s not necessarily a sign that the contract is a scam – but it is a pretty essential piece of data that you don’t have access to, and that needs to be factored into your decision.
The Bottom Line: Knowledge is Power
No matter how much you read about crypto, your best defense against scams is good judgment and a knowledge of the data you’re working with. With all this info, you are now ready to do a basic assessment for yourself to understand exactly what sort of smart contract you’re interacting with.
Scammers have gotten to even the OGs of the crypto industry. So every second that you spend learning about security is an investment in yourself – that’s what Ledger Academy is here to help with. Check out our security series here and always stay a step ahead of the scammers.
The whole point of blockchain was to put YOU in the driving seat. So keep on learning and stay on top of this space, because the more you know, the more you can benefit from this incredible space!
Knowledge is power.
Now you know how to read a smart contract, let’s take a deep dive into what they’re doing and how it might benefit you. Thanks School of Block!