Codecademy Logo

Smart Contracts, NFTs, and DAOs

Drawbacks of a DAO

Drawbacks of a DAO:

  • Because of the decentralized and autonomous nature of DAOs, they can often lack cohesive leadership and direction.
  • DAOs are still new, and the tooling to manage them can be clunky and difficult to use.

Decentralized Autonomous Organization

A decentralized autonomous organization (DAO) is a group of smart contracts that are concerned with a group of people making decisions.

Benefit of DAO: Transparency

A major benefit of a DAO is transparency. Decisions are made publicly.

Smart Contracts in a DAO

In a DAO, smart contracts are used to enforce both voting processes and treasury management.

Voting is Required for a Change in a DAO

Once a DAO is formed, requires a certain amount of votes to change anything.

Governance Tokens

DAOs utilize governance tokens issued to members to determine voting rights.

Benefits of a DAO

Benefits of a DAO:

  • Ownership and decision-making power are distributed among all members.
  • Smart contracts allow for automating processes based on the results of voting on a proposal.
  • Allow for groups of people with aligned incentives to self-organize around a common goal.

NFT Burn Function

An NFT burn function allows a user to permanently destroy an NFT.

ERC-721 Token Standard

Ethereum uses the ERC-721 token standard for NFT creation. This standard is represented by the ERC-721 class in OpenZepplin.

NFT on the Bitcoin Blockchain

It is not possible to create an NFT directly on the Bitcoin blockchain.

NFT on the Solana Blockchain

NFTs are popular on the Solana blockchain because of its use of the Metaplex framework.

Fungible Token

In blockchain, a token is considered fungible if every token is worth as much as every other token; i.e., there is only one denomination.

Non-Fungible Token (NFT) Anatomy

An NFT is comprised of:

  • Token name
  • Token ID
  • Token URI
  • Owner
  • Mint function
  • Transfer function
  • Burn function

NFT Token Name

An NFT token name is the representation of what the NFT collection is called.

NFT Token ID

An NFT token ID is an integer that uniquely identifies an NFT.

NFT URI

An NFT token URI is a set of data that defines a token’s traits.

NFT Mint Function

An NFT mint function allows a user to create an NFT.

NFT Transfer Function

An NFT transfer function allows a user to transfer ownership of an NFT.

Non-Fungible Tokens (NFTs)

Non-Fungible Tokens (NFTs) can be thought of as records of ownership represented on the blockchain.

These records of ownership are cryptographically verified and permanently stored on the blockchain.

An image showing that ownership of assets is recorded by an NFT.

Smart Contracts in Gaming

In gaming, smart contracts are in the form of NFTs. Gamers can purchase digital items in which they exchange money for a record of ownership of some digital item.

Immutability of Smart Contracts

Smart contracts are immutable. This means they cannot be changed.

Smart Contracts and Trustlessness

Smart contracts should be used for any piece of functionality that needs to be trustless. In other words, smart contracts should be used when we don’t want to trust a singular, central intermediary with a task.

This could be due to fears of corruption or other reasons.

Uses of Smart Contracts

A few common use cases of smart contracts are:

  • Finance
  • Gaming
  • Legal
  • Real Estate
  • Corporate Structures

Decentralized Finance (DeFi)

Decentralized Finance (DeFi) aims to use blockchain to replace a central bank with code. However, because there is no central entity to govern a DeFi blockchain, this technique is vulnerable to security issues.

Smart Contracts in Law

Smart contracts have applications in the legal world. It is possible to encode legal documents as smart contracts.

Smart Contracts in Real Estate

In real estate, smart contracts can be used to store data such as the building agreement, the mortgage process, the title, the municipal record keeping, and inspections. These would be stored in the form of an NFT.

Disadvantage of Smart Contracts: Reentrancy

One of the pitfalls of smart contracts is a security issue known as reentrancy. Reentrancy occurs when external contract calls are allowed to make calls to the caller contract before execution finishes.

This can result in calls being allowed that should not have been allowed because the calls slipped in before a relevant execution finished.

Disadvantage of Smart Contracts: Public Access

A security issue that smart contracts face is access control. This is because all smart contracts code is publicly accessible and callable.

Languages Used to Create Smart Contracts

The three main languages used to build smart contracts are:

  • Solidity
  • Clarity
  • Rust

Solidity

Solidity is a language used to write smart contracts that is object-oriented and Turing complete. The syntax is similar to JavaScript.

Clarity

Clarity is a language used to write smart contracts that is decidable and Turing incomplete. It doesn’t allow looping.

Learn more on Codecademy