SANS

GERARD

Developer Evangelist

Developer Evangelist

International Speaker

Spoken at 168 events in 37 countries

Serverless Training

Serverless Training

What if you owned the Web?

〞

Web3 is an internet

owned by users and builders

orchestrated with tokens.

– Chris Dixon

Web3

  • Social Media
  • Applications
  • Corporations monetise data
  • Centralised
  • Hosted privately
  • Manually programmed

Web2  vs  Web3

  • Metaverse (VR & AR)
  • Distributed Apps (dApps)
  • Users monetise data (NFT)
  • Distributed
  • Public blockchain
  • AI driven

Web3 Universe

DAOs

NFTs

Decentralised Storage

Metaverse

Crypto

Blockchain

Smart Contracts

DeFi

Blockchain

Blocks

Block N-1

Block N

Data

Hash

Block N-2

Coin

Consensus

PoW/PoS

Immutable Ledger

Wallet (Address)

P2P

Decentralised

Cryptography

SHA256

Fundamentals

Wallets types

Hot Wallet

Cold Wallet

Social Recovery

MetaMask Wallet

Wallet information

Address

Private Key

Public Key

hash

hash

Signing and verification

Sofia

0xA0

John Wick

0xF1

Mining

Transaction

Transaction

Verification

Signing

Transactions

1 ETH

2 ETH

Sofia

0xA0

2 ETH

John Wick

0xF1

3 ETH

Sofia

0xA0

1 ETH

John Wick

0xF1

1 ETH

Pending

Confirmed

Miners, full nodes and SPVs

Miner

Miner

Miner

SPV

SPV

SPV

Full Node

Full Node

Full Node

Full Node

Full Node

Full Node

Mining (PoW)

Block N-2

Block N-1

Block N

Mining (PoW)

Block N-2

Block N-1

Block N

Block N-2

Block N-1

Block N

Mining (PoW)

Verifying

Block N-2

Block N-1

Block N

Cycle repeats

Block N-3

Block N-2

Block N-1

Block N

Blockchains comparison

Year 2009 2015 2017 2020 2020
Consensus PoW PoW PoS PoS* PoH
Tps 7 17 250 1K 65K
Tx finality 30-60 min 6min 2 min 30s 1s

Polkadot (DOT)

Solana (SOL)

Cardano (ADA)

Ethereum (ETH)

Bitcoin(BTC)

Ethereum

Ethereum Accounts

Externally Owned Account

Contract Account

Coins vs Tokens

ETH

Tokens

ERC-20

NFTs

ERC-721

Multi-token

ERC-1155

Ethereum Development

Client

HTML/CSS/JS/ether.js

MetaMask

Wallet Extension

Frontend

Ethereum

Mainnet

Ropsten

Kovan

localhost

Rinkeby

Deploy

Transactions

Contract

API calls

SOL

Smart Contracts

Smart Contracts

Deploy

Code

Compile

Test

Development Cycle

pragma solidity >=0.4.16 <0.9.0;

contract HelloWorld {
    string public message = "Hello World!";
}

Smart Contract: HelloWorld v1

pragma solidity ^0.8.10;

contract HelloWorld {
    string message = "Hello world!";

    function set(string memory _msg) public {
        message = _msg;
    }

    function get() public view returns (string memory) {
        return message;
    }
}

Smart Contract: HelloWorld v2

pragma solidity ^0.8.10;

contract Example {
    function globalVariables() {
        address payable sender = msg.sender;
        uint256 value = msg.value;
        bytes data = msg.data;
    }
}

Global variables (window)

Static types

uint256 mintReward = 1000;
uint mintReward = 1000;


address player = address(0);


string msg = unicode"🚀";
let mintReward = 1000;



let player = 0x0;


let msg = "🚀";

Functions

function mint(address to, uint256 amount) public {
    _mint(to, amount);
}
function mint(to, amount) {
  this._mint(to, amount);
} 

uint256 vs number vs BigInt

uint256 x = 9999999999999999;
let fails = 9999999999999999;  // 10,000,000,000,000,000
let works = 9999999999999999n; //  9,999,999,999,999,999

Testing: HelloWorld v2

Real world Example

Gaming coins

Economics of utility tokens

Fixed Reserve Value

1x Helmet

5x GLD

Economics of utility tokens

Minumum cost

y=\frac {\sqrt x} x

Minimum GLD cost per token (Logarithmic scale)

Max supply

GLD/Unit

Economy of scale

interface ERC20 {
  function totalSupply() external view returns (uint);
  function balanceOf(address who) external view returns (uint);
  function transfer(address to, uint value) external returns (bool);
  function allowance(address owner, address spender) external view returns (uint);
  function transferFrom(address from, address to, uint value) external returns (bool);
  function approve(address spender, uint value) external returns (bool);
  
  event Approval(address indexed owner, address indexed spender, uint value);  
  event Transfer(address indexed from, address indexed to, uint value);
}

Gaming coin: GLDToken ERC20

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract GLDToken is ERC20, Ownable {
    constructor(uint256 initialSupply) ERC20("Gold", "GLD") {
        _mint(msg.sender, initialSupply);
    }
    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

Gaming coin: GLDToken ERC20

# Setup
> npm install @openzeppelin/contracts
> npx hardhat compile
> npx hardhat node

# Deploy
> npx hardhat run --network localhost deploy.js

# Stop
> npx hardhat clean

Setup: GLDToken ERC20

// scripts/deploy.js

const GLDToken = await ethers.getContractFactory("GLDToken");

// execute transaction
const token = await GLDToken.deploy('1000');

// wait for transaction to be part of the blockchain
await token.deployed();

Deploy Script: GLDToken ERC20

// GLDToken.js

const token = await ethers.getContractAt("GLDToken", player);
await token.balanceOf(player);
// 10

await token.transfer(defenseOftheAncients2, 3);
await token.balanceOf(player);
// 7

Usage: GLDToken ERC20

Web3 is all

about tokens!

How are you going to use them?

More

Ethereum Basic Toolbelt

Metamask

Wallet

Etherscan

Browser

OpenZeppelin

Smart Contracts

Remix

Smart Contracts

Web3 Architecture

Decentralised Identity

Decentralised Apps

UX

Blockchain

Web3 Ecosystem

Decentralised Storage

Decentralised Computing

Ethereum and smarts contracts for JavaScript Devs

By Gerard Sans

Ethereum and smarts contracts for JavaScript Devs

In this talk I will present the state of the art for web3, decentralized architectures and tools. You will learn how simple it is to create your own decentralised app using your current coding skills and JavaScript! Ethereum is also the platform that runs smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third party interference. Join to learn all the potential for Ethereum blockchain!

  • 1,546