Comment on page
A smart contract is computer code that is run by a blockchain network. Smart contracts are used to create decentralised applications (DApps). The purpose of these applications is broad, for instance, some of the common use cases include:
- The creation of tokens such as digital currencies, utility tokens or non-fungible tokens (NFTs)
- The creation of governance structures for protocols
- Wallets that can be managed by more than one user (known as multi-sig wallets)
- Decentralised finance applications such as exchanges, stablecoins and lending markets
- Creating decentralised autonomous organisations (DAOs)
The limits of what can be created are only really restricted to the imagination of developers. There are physical constraints with smart contracts — a blockchain network is a massively decentralised computer which is slow and resource constrained, so you can’t create media-rich applications on them. What they are great at is recording the state of a specific application at a point in time, such as ownership of a digital or real-world asset.
Smart contracts are deployed to a blockchain network using an account. That account creates a transaction, and if successful, the smart contract is deployed to that network. The smart contract then has an address associated with it, which is used to interact with that smart contract. This type of address takes the same format as a wallet address.
In order to simplify working with smart contracts, standard interfaces have been developed for blockchain networks which describe some of the properties of that contract. This enables users to understand some of the behaviours of that contract and the intent of that contract without having to go through the source code.
The smart contracts view in Chainlens
For instance, in the contracts view of Chainlens, you can see all of the various contracts that have been deployed on the network. The type field defines if it supports a well-known interface (ERC-20 and ERC-721 are two of the best known on Ethereum which we’ll cover when we discuss tokens). Then you can also see its address and various other information about it.
Making sense of smart contracts is non-trivial without understanding their intent. The best way to understand them is via the standard interfaces they support. In the case of Ethereum, you have ERC proposals (Ethereum Requests for Comment), which propose standards which are scrutinised and reviewed by the community, before in some instances becoming standards.
The ERC standards are listed here. Rather than trying to understand them all, it's best to start with the two major token standards ERC-20 and ERC-721. These are used to represent fungible and non-fungible tokens (NFTs) which are discussed in detail in the tokens section.
In order to consume information about smart contracts running on Ethereum blockchains, when you navigate to a contract on Chainlens if the contract source code has been uploaded, it can provide additional information about the contract by interacting with it directly.
This functionality allows users to obtain information about the state and assets contained in the contract such as token details and owners if it's a token contract. In addition, users can connect Web3 wallets to Chainlens to transact directly with the contract.
Smart contracts are code that is deployed using an account to a blockchain. When they are deployed successfully, they have an address on the blockchain which is used to interact with them.
Standard interfaces are used for representing common functionality in smart contracts such as tokens. The interfaces in Ethereum are defined using ERC standards. The best known ERC standards are ERC-20 and ERC-721 which represent fungible and non-fungible tokens (NFTs).
It’s possible to query and obtain additional information about live smart contracts on Ethereum using Chainlens.