andywan

Posted on Jan 09, 2022Read on Mirror.xyz

How to read a smart contract?

https://twitter.com/chriscantino/status/1480300076786274304

How to read a smart contract—and why you’d want to in the first place.

Reading a smart contract gives you insight into the popularity of a project, how distributed its ownership is, and what it’s capable of. Plus, you can investigate the details of every transaction. A big advantage in web3. One day, they’ll probably teach this stuff in schools.

First, what is a smart contract? It’s a program that executes code on the blockchain when conditions are met. Parties sign the contract digitally, giving it permission to execute. This could be anything from sending money to a friend, to fractionalizing an NFT.

So, how do you find a smart contract? Ethereum contracts, transactions, and wallets are browsable on

@etherscan

. To look up an NFT contract, navigate to the listing on OpenSea and tap “Details.” This reveals a “Contract address” link. Click it.

Lots to look at here, so let’s break it down. Balance + Value This shows how much coin the contract holds. My Name Tag If logged in, you can create private notes to yourself here. Creator The wallet that created the contract, and a link to the original tx. Let’s click it.

Here we have details on the transaction that created the contract. We can see: -Transaction confirmation -Timestamp -Quantity minted of each token -Contract creator -Fees paid Good stuff. Now, back to the main contract.

Tracker Let’s click for insight into: -minimum token value -max total supply of the token (if a maximum has been set) -how many wallets hold the token -how many transfers have occurred Very valuable info. But there’s another cool thing here that most people don’t know about.

Click “Holders” in the list of tabs. This displays a ranking of who holds the most tokens in the contract. If you click “Token Holders Chart,” you can even see a chart. OK, back to the main contract page.

Let’s dive into the “Transactions” tab. Column 1 is a chronological list of all transactions. Each can be clicked into. Next is “Method.” These are functions executed via the contract. Every contract is different, but common methods include mint, transfer, and approval setting.

Now, let’s investigate the “Contracts” tab. Code: Displays the contract’s source code. Read Contract: Displays the functions. Write Contract: Allows you to initiate functions (if your wallet has permission) like burning tokens, granting roles, pausing, and more.

Finally, let's check “Analytics.” Here, we find charts showcasing transactions, fees, ETH balance, and more. The chart below highlights the rise of Cryptopunks. I also recommend

@nansen_ai

for more detail on volume, project wallet overlaps, notable token holders, and more.

That concludes Contract Reading 101! Now you're better equipped to interact with web3 contracts. For more web3 how-tos, follow along with me @chriscantino. Thx for reading.