React hooks to easily integrate Wavelet smart contracts into your React application.
yarn add react-use-wavelet
import React useCallback useState from "react";import useWavelet useAccount useContract from 'react-use-wavelet';import Wavelet from 'wavelet-client';import JSBI from "jsbi";const BigInt = JSBIBigInt;const MyAccount =// First get a working clientconst client node clientErr = ;// To get a Wavelet Accountconst account accountErr = ;const chatLogs setChatLogs = ;// callback to set chat logs to results of contract 'get_messages' functionconst loadLogs =;// load logs every time wavelet reaches consensus;const onUpdate = loadLogs;// load logs after contract loadsconst onLoad = loadLogs;// To get a Wavelet Contract, and register callbacksconst contract = ;// To call a contract functionconst sendMessage = messageconst wallet = Wavelet;contract;return<div>Balance: account ? accountbalance : 'account not loaded'Public Key: account ? accountpulic_key : 'account not loaded'<button = /><textarea==/></div>
You can use
client objects in the same way as documented in the wavelet-client-js docs