Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Smart Contract Development with Solidity: A beginner's guide

Smart Contract Development with Solidity: A beginner's guide

Smart Contract Development with Solidity: A beginner's guide.

Code Africa Conference(Online), November 2023

Olubisi Idris Ayinde

November 23, 2023
Tweet

More Decks by Olubisi Idris Ayinde

Other Decks in Technology

Transcript

  1. Smart Contract
    Development with Solidity:
    A beginner's guide
    Code Africa Conference
    November 2023

    View full-size slide

  2. Idris Olubisi
    Developer Advocate, Axelar
    @olanetsoft

    View full-size slide

  3. What will you learn in this talk?
    ● Introduction to blockchain
    ● What is a smart contract and why use solidity?
    ● Solidity basics and syntax
    ● Development tools and testing
    ● Best practices and security considerations
    ● Building, compiling and deploying smart contracts

    View full-size slide

  4. Do you have any idea what Blockchain is ?

    View full-size slide

  5. What is a Blockchain?
    A blockchain is a digital ledger of transactions, duplicated and
    distributed across a network of computer systems.

    View full-size slide

  6. Blockchain == Smart Contract ?

    View full-size slide

  7. "From 1989 to 2001, there were almost no
    legitimate winners of the high-value game
    pieces in the McDonald’s Monopoly game"
    FBI Special Agent Doug Mathews

    View full-size slide

  8. Smart Contract

    View full-size slide

  9. What is a Smart Contract?
    A smart contract is a self-executing contract with the terms of the agreement
    between buyer and seller being directly written into lines of code and can be
    deployed on the blockchain.

    View full-size slide

  10. Blockchain != Smart Contract

    View full-size slide

  11. Solidity: Basics and Syntax

    View full-size slide

  12. Variables in Solidity
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;
    contract Example {
    int public count; // Integer variable
    bool public isActive; // Boolean variable
    address public userAddress; // Address variable
    }

    View full-size slide

  13. Functions in Solidity
    contract Example {
    uint private storedData;
    function set(uint x) public {
    storedData = x;
    }
    function get() public view returns (uint) {
    return storedData;
    }
    }

    View full-size slide

  14. Data Types in Solidity
    contract DataTypes {
    bool public isTrue = false;
    uint public num = 123;
    address public userAddress;
    struct Person {
    uint id;
    string name;
    }
    Person public person = Person(1, "Alice");
    }

    View full-size slide

  15. Basic Structure of a Solidity Contract
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;
    contract SimpleContract {
    uint public count;
    function setCount(uint _count) public {
    count = _count;
    }
    function incrementCount() public {
    count += 1;
    }
    }

    View full-size slide

  16. Development Tools and Testing

    View full-size slide

  17. Integrated Development Environments (IDEs)
    ● Remix
    ● Chain IDE
    ● Visual Studio Code

    View full-size slide

  18. Development Frameworks
    ● Hardhat
    ● Foundry
    ● Truffle Suite

    View full-size slide

  19. Blockchain Networks
    ● Testnet
    ● Mainnet

    View full-size slide

  20. Automated Testing
    ● Truffle, Foundry and Hardhat offer frameworks for writing and
    running automated tests
    ● Mocha and Chai can be used in conjunction with these frameworks
    for more advanced testing

    View full-size slide

  21. Automated Testing: Type of Test
    ● Unit tests for individual functions
    ● Integration tests for contract interactions
    ● Fuzz test

    View full-size slide

  22. Programming Languages for writing Smart
    Contracts

    View full-size slide

  23. Programming Languages for writing Smart
    Contracts
    ● Solidity
    ● Rust
    ● Vyper
    ● Cadence
    ● Cargo

    View full-size slide

  24. Security and Best Practices

    View full-size slide

  25. Security and Best Practices
    Common vulnerabilities
    ● Re-entrancy
    ● Integer overflows/underflows
    ● Access control issues
    ● Unsafe external calls
    ● Front-running
    ● Denial of service

    View full-size slide

  26. Security and Best Practices
    Best practices
    ● Use tested libraries and frameworks
    ● Keep contracts simple
    ● Add revert conditions
    ● Validate inputs and outputs
    ● Adhere to check-effects-interactions pattern
    ● Extensive testing

    View full-size slide

  27. Security and Best Practices
    Avoiding mainnet deployments
    ● Use Remix to deploy initially
    ● Deploy to testnets first
    ● Run through multiple test cases
    ● Upgradeability best for mainnet

    View full-size slide

  28. Resources and Communities
    ● Solidity docs
    ● OpenZeppelin contracts
    ● 32 hrs course by Patrick Collins
    ● LearnWeb3.io
    ● Alchemy University

    View full-size slide

  29. Communities
    ● Developer DAO
    ● Web3 Afrika
    ● Web3Bridge
    ● LearnWeb3
    ● Web3 Ladies

    View full-size slide

  30. I’m rooting for you!

    View full-size slide

  31. Thank You!
    @olanetsoft

    View full-size slide