/iotex-dapp-sample

This is a boilerplate template for making your awesome dApp on IoTeX and ETH, BSC, and other EVM compatible chains

Primary LanguageTypeScript

IoTeX dApp Sample V3

7121622212283_ pic

This is a boilerplate template for making your awesome dApp on IoTeX and ETH, BSC, and other possible chains (request here)

Technology used in this template are

Intro

A starter for React with Typescript with the fast Vite and the beautiful Matine, tested with the powerful Cypress.

Cheat Sheet

Here's a cheat sheet list to help you get started quickly

import { rootStore, useStore } from '@/store/index';

const { god } = useStore();
// or const god = rootStore.god

god.isConnect;

god.currentChain;
god.currentChain.chainId; // for current connected chain id
god.currentChain.Coin; // eth/bnb/iotx
god.currentChain.Coin.balance; // current balance
// ... see ChainState

god.currentNetwork;
god.currentNetwork.account; // for current connected account address
// ... see NetworkState

god.setShowConnecter(); // to show/close the Wallet Selector

god.currentNetwork.loadBalance(); // to load chain coin balance

await rpc('query')({
  UniswapRouter: [
    { calls: [{ address: '0x95cB18889B968AbABb9104f30aF5b310bD007Fd8', chainId: 4689 }] },
    {
      swap: [
        {
          args: {
            sellToken: 'BUSD_b',
            buyToken: '0xb8744ae4032be5e5ef9fab94ee9c3bf38d5d2ae0',
            buyAmount,
            recipient: '0x2AcB8663B18d8c8180783C18b88D60b86de26dF2',
            offlinePrice: true
          }
        },
        {
          amount: true,
          data: true,
          router: true,
          path: {
            address: true,
            symbol: true,
            decimals: true,
            totalSupply: true
          }
        }
      ]
    }
  ]
});

Generate sdk

$ npm i @smartgraph/cli -g
$ yarn dev
$ smartgraph codegen -l http://localhost:3000/api/graphql -o ./src/lib

Installation

Clone the repo and run yarn install

Start

After the successfull installation of the packages: yarn start

Tests

You can build tests with Cypress. I wrote a small test to see if it's enabled. You can run it with yarn test