gm

Blockchain Designed Front-End

question

web3 now

you tell me!

♥️

question

feature?

button?

♥️

Steve Wojak
web 3 sign in

web 1

web 1 sign in

web 2

web 2 sign in

web 3

web 3 sign in
Kuba Pusiak

Kuba

React, TypeScript, Web3

IPOR Labs

TradFi ➡️ DeFi

YouTube: JS Dżem

dApps

Disclaimer

  • My stack = React.js
  • EVM compatible chains

Why blockchain?

  • ready to use platform
  • ownership out of the box
  • open source

web3 ➡️ blockchain

web2 ➡️ backend

a node

❌ node.js

Node providers

Infura Infura
Alchemy Alchemy
  • ✅ read
  • ✅ write 👛
  • ❌ put
  • ❌ delete

web2

web3

😥
🥹
😄
🤝
😎

0x5981ac4718e35aE03F5533290eD204a767148450

A P B I

application    programming binary schema    interface

schema


						const provider = new ethers.providers.Web3Provider(
        window.ethereum
      );
						await provider.send("eth_requestAccounts", []);
						const contract = new ethers.Contract(
        address,
        abi,
        provider,
      );
						await contract.mintMyNFT()
					

Reading

  • free 🆓
  • no wallet required
  • () ⇒ Promise<Result>
  • no event emitted

Writing

  • costs you to pay for gas
  • wallet required
  • 
                    () ⇒ Promise<{ 
                      wait: () ⇒ Promise<Receipt>
                    }>
                  
  • can emit events
MetaMask

wallet

identity

account

token owner

value

Challenges
for
front-end devs

JS math

BigNumber

*18 decimals precisions

*only integers


            const myBalance = BigNumber.from('8920584203949257369');
					

            const myBalance = BigNumber.from('8920584203949257369')
              .div('24342667722')
              .mul('58407229393064');
					

Primitive BigNumber  Obsession


            const collateral = BigNumber.from('5000000000000000000000');
            const interestRate = BigNumber.from('8920584203949257369');
            const total = BigNumber.from('5180000000000000000000');
					

            function openSwap(total: BigNumber) {
              ...
            }
					

            function openSwap(total: Total) {
              ...
            }
					

            type Total = BigNumber & {
              __brand: 'TOTAL';
            };
					

            BigNumber.from('5000000000000000000000') as Collateral;
            BigNumber.from('8920584203949257369') as InterestRate;
            BigNumber.from('5180000000000000000000') as Total;
					

Real time UI

The old way

  • refresh data in relevant interval
  • update when transaction affects your data
  • filter out redundant calls
  • manage priority
📦 📦 📦 📦 📦
🕛
React.js
Redux

RxJS

useDapp
useDapp
Multicall + block change detecting
=
real time UI
test pyramid

E2E


integration


unit


Run in real browser with real wallet

what parts involved? local blockchain facade

smart contracts      components


Cypress + MetaMask = Synpress


@testing-library


@testing-library

Error logging

How mouch cost developing?

grab the slides

QR code to those slides