2.4.0 • Published 2 years ago
zam-sdk v2.4.0
Zam Chat SDK
Let's follow steps to install sdk inside your react js game application for having in game chat sdk
Installation
npm install zam-sdk
or
yarn add zam-sdk
Add SDK in your game
Now checkout to component where you want to embed chat add outside return of component
Imports
import ZamChatSDK from zam-sdk/lib/App
const [currentAccount, setCurrentAccount] = useState("");
const connectWallet = async () => {
try {
// @ts-ignore
const {ethereum} = window;
if (!ethereum) {
alert("Get MetaMask!");
return;
}
const accounts = await ethereum.request({method: "eth_requestAccounts"});
console.log("Connected", accounts[0]);
setCurrentAccount(accounts[0]);
} catch (error) {
console.log(error)
}
}
Add inside the return anywhere
<ZamChatSDK connectWallet={connectWallet} currentAccount={currentAccount} setCurrentAccount={setCurrentAccount}/>} />
Now lets run and see
npm start