1.0.3 • Published 2 years ago
@squirrelverse/web3 v1.0.3
Using web3 functions made easy by SquirrelVerse.
Install package
npm install @squirrelverse/web3
Functions available
There are two functions available for you to use:
import {
getMetaMaskProvider,
getMetaMaskSigner,
getAccountInfo,
} from "@squirrelverse/web3"
Use
getMetaMaskProvider()
to get your metamask provider.Use
getMetaMaskSigner()
to get your metamask signer.Use
getAccountInfo()
to get your metamask wallet address.
Here's an example code:
import { getAccountInfo } from "@squirrelverse/web3"
import { useState } from "react"
export default function App() {
const [info, setInfo] = useState("")
const handleClick = async () => {
const account = await getAccountInfo()
setInfo(account)
}
return (
<div className='App'>
<h1>Hi there</h1>
<button onClick={handleClick}>
{info === "" ? "connect wallet" : info.substring(0, 10)}
</button>
<h2>
{info === "" ? "Connect you account" : `your account address: ${info}`}
</h2>
</div>
)
}