Skip to content

Repository files navigation

dether.web3

Run example

  • Google Chrome
  • Metamask

TODO

  • Check if the user is logged

Build the package

yarn build

Creage new React app

cd examples
npx create-react-app test
cd ..

Copy lib directory to node_modules

mv lib detherweb3
mv detherweb3 examples/test/node_modules

Copy package json

cp package.json examples/test/node_modules/detherweb3
cd examples/test/node_modules/detherweb3
yarn
cd ../../../

Copy example.js to src

cp example.js test/src

Remove everything in src/index.js and paste this code

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import './example';
ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();

Run the app and watch the console on the browser

cd test/
yarn start

Update the Build

yarn build
cp -r lib/* examples/test/node_modules/detherweb3/

Usage

Instanciate

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()}catch(e){console.log(e)}

Methods

Get Balance

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()constbalances=awaitdetherWeb3.getBalance();console.log(balances);}catch(e){console.log(e)}

Is sms registered

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()constisSmsReg=awaitdetherWeb3.isSmsReg();console.log(isSmsReg);}catch(e){console.log(e)}

Get zone price

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()constzoneId='GI'constzonePrice=awaitdetherWeb3.getZonePrice(zoneId);console.log(zonePrice);}catch(e){console.log(e)}

Get transaction status

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()consthash=''// ethereum transaction hashconsttransactionStatus=awaitdetherWeb3.getTransactionStatus(hash);console.log(transactionStatus);}catch(e){console.log(e)}

Is zone open

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()constzoneId='GI'constopen=awaitdetherWeb3.isZoneOpen(zoneId);console.log(open);}catch(e){console.log(e)}

Get shop

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()constshop=awaitdetherWeb3.getShop();console.log(shop);}catch(e){console.log(e)}

Delete shop

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()consthash=awaitdetherWeb3.deleteShop();console.log(hash);}catch(e){console.log(e)}

Add shop

importDetherWeb3from'detherweb3';try{constdetherWeb3=newDetherWeb3();awaitdetherWeb3.init()constdata={lat: 1.23,lng: 12.324,countryId: 'GI',postalCode: '34584',cat: 'catch',name: 'name',description: 'desc',opening: '0000000',};consthash=awaitdetherWeb3.addShop(data);console.log(hash);}catch(e){console.log(e)}

Getters

Get ethereum address

constaddress=detherWeb3.ethAddress;

Get network id

constnetworkId=detherWeb3.network;

Is web3

constisWeb3=detherWeb3.isWeb3;

Is connected

constisConnected=detherWeb3.isConnected;

Is initialized

constisInit=detherWeb3.isInit;

TODO

  • Add more test
  • Add tellers feature
  • Add DTH transfer feature

About

Gateway between Front App and the detherContracts using Web3js

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages