Skip to content

Instantly share code, notes, and snippets.

View MCarlomagno's full-sized avatar
🚀

Marcos Carlomagno MCarlomagno

🚀
View GitHub Profile
@MCarlomagno
MCarlomagno / metamask.ts
Last active July 19, 2023 22:36
🦊🪝 React hook for Metamask extension using ethers.js. The hook includes some of the most common use cases such as wallet connection, events listening, transaction, addresses and signer management.
import * as ethers from 'ethers';
import {
ExternalProvider,
JsonRpcSigner,
Network,
Web3Provider
} from '@ethersproject/providers';
import { useState } from 'react';
declare global {
pragma solidity >=0.7.0 <0.9.0;
contract Chat {
// ...
// We can use an autoincremental id for each new message.
uint lastMessageId;
function sendMessage(string _text) public {