Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

Idris Olubisi Developer Advocate, Axelar @olanetsoft

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Do you have any idea what Blockchain is ?

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

Blockchain == Smart Contract ?

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

"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

Slide 9

Slide 9 text

Smart Contract

Slide 10

Slide 10 text

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.

Slide 11

Slide 11 text

Blockchain != Smart Contract

Slide 12

Slide 12 text

Solidity: Basics and Syntax

Slide 13

Slide 13 text

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 }

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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"); }

Slide 16

Slide 16 text

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; } }

Slide 17

Slide 17 text

Development Tools and Testing

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Development Frameworks ● Hardhat ● Foundry ● Truffle Suite

Slide 20

Slide 20 text

Blockchain Networks ● Testnet ● Mainnet

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

Programming Languages for writing Smart Contracts

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

Security and Best Practices

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

I’m rooting for you!

Slide 32

Slide 32 text

Thank You! @olanetsoft