Fireship · @fireship

Solidity in 100 Seconds

Uploaded September 27, 2021 · Length 2:22

Solidity in 100 Seconds

Summary

solidity programming language for smart contracts on blockchain, explained in 100 seconds.

  • solidity
  • smart contracts
  • blockchain programming
  • ethereum
  • web3

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    Solidity, a statically typed, compiled programming language for implementing smart contracts.

  2. 0:05

    The concept of a smart contract has been around since 1994, when Nick Szabo described it as

  3. 0:10

    a digital vending machine.

  4. 0:12

    It's just code and data that govern the behavior of accounts on the blockchain.

  5. 0:16

    For example, Bob might agree to pay Alice for a service, so they deploy a smart contract

  6. 0:21

    to the blockchain that's its own independent account.

  7. 0:24

    The contract is not controlled by humans, but rather its own internal code, so it can't

  8. 0:28

    be manipulated and no lawyers are needed for interpretation. When the services are rendered

  9. 0:34

    to Bob, the contract will execute and transfer funds to Alice. There are many other potential

  10. 0:39

    use cases, like Web3 decentralized apps, decentralized financial products or DeFi,

  11. 0:45

    or to trade digital assets in the form of non-fungible tokens. In fact, you could be the

  12. 0:50

    proud owner of this very YouTube video as an NFT. Solidity is a high-level language for writing

  13. 0:55

    smart contracts with a syntax that resembles many curly-braced languages, like C++ or TypeScript.

  14. 1:01

    It's statically typed and supports object-oriented patterns like inheritance.

  15. 1:05

    It came to life in 2014 and is most commonly associated with Ethereum but it supports multiple blockchain platforms To code a smart contract create a file ending in Use the pragma keyword at

  16. 1:16

    the top to tell the compiler which version of Solidity to use. Then use the contract keyword

  17. 1:21

    to define the details of the smart contract. It's roughly equivalent to a class in other

  18. 1:25

    programming languages. Inside the braces, we can define state or variables where the value might

  19. 1:30

    change throughout the lifecycle of the contract. The language also has special data types like

  20. 1:34

    address to hold a 20-byte Ethereum address. The struct keyword allows you to create more complex

  21. 1:40

    data types, usually to represent the different entities in the contract. Use the function keyword

  22. 1:45

    to define executable blocks of code, which might be called upon at some point to modify the state

  23. 1:49

    of the contract. You can also define a constructor that's only called once when the contract is first

  24. 1:54

    created. When the constructor is finished executing, your code will be deployed on the blockchain.

  25. 1:59

    After the contract has been defined, you then compile it, so you can use it programmatically