https://github.com/d3portillo/usemetamask
Utility React hook to handle Metamask's browser API
https://github.com/d3portillo/usemetamask
crypto hook metamask react-hooks reactjs web3
Last synced: 6 months ago
JSON representation
Utility React hook to handle Metamask's browser API
- Host: GitHub
- URL: https://github.com/d3portillo/usemetamask
- Owner: D3Portillo
- License: mit
- Created: 2022-05-19T21:38:25.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T22:58:40.000Z (over 3 years ago)
- Last Synced: 2025-04-01T23:55:29.092Z (6 months ago)
- Topics: crypto, hook, metamask, react-hooks, reactjs, web3
- Language: TypeScript
- Homepage: https://forta.vercel.app/usemetamask
- Size: 262 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# useMetamask 🦍
![]()
An utility React hook to handle Metamask's browser API
## Installation
```bash
npm i @forta/usemetamask
```## Getting Started
```js
import { useMetamask } from "@forta/usemetamask"function App() {
const { account, connect, balance } = useMetamask()
return (
Address: {account}
BALANCE: {balance}ETH
CONNECT
)
}
```## Send Ether
```js
import { parse, useMetamask } from "@forta/usemetamask"
// ..const { send } = useMetamask()
send({
to: "0x3c0e20fCA6d2E084127D056377a5f35294503447",
value: parse.toTxWei(0.5),
/* 0.5 in ETH. Request expects wei in HEX value.
.toTxWei parses a number to wei & then to HEX */
})
```---
**[READ THE DOCS 🌟](https://forta.vercel.app/usemetamask)** | **[FOLLOW ME 🐦](https://twitter.com/d3portillo)**