npm.io
1.0.0 • Published 3 years ago

@eztools-core/web3context

Licence
MIT
Version
1.0.0
Deps
2
Size
75 kB
Vulns
0
Weekly
0

@eztools-core/web3context

A simple React context wrapper to access web3 functions and integrate smart contracts.

Install

npm install --save @eztools-core/web3context

Usage

Initialize the provider at the root of your project (App/index.tsx)

import React, { Component } from 'react'
import { Web3Provider } from 'Web3Context'

const App = () => {
  return <Web3Provider>// App Code goes here</Web3Provider>
}

Use the context anywhere in your app

import { useWeb3Context } from 'Web3Context'

const Component = () => {
  const { account, connectWallet, contractObjects } = useWeb3Context()
  return (
    <>
      <div>Connected Address: {account}</div>
      <br />
      <button onClick={connectWallet}>Connect Wallet</button>
    </>
  )
}

License

MIT mysteriousacadia