Metamascara Example

Open-source Object-oriented Web3 library.

It's 100% compatible with vanilla javascript (like this example), typescript (angular), and modern javascript (react / vue).

Let us know if you are using it. We can add your project to our list.

Example 1. Connect your wallet

Connected to: -

const { MetaMascaraFactory } = mmascara;
const instance = MetaMascaraFactory.newInstance();
//  isConnected will be true if the user has connected their wallet
const isConnected = await instance.connect();
if (isConnected) {
  console.log(`Connected to ${instance.networkName}.`);
}

Example 2. Add and/or select a network

const { MetaMascaraFactory, blockchainConnections } = mmascara;
const instance = MetaMascaraFactory.newInstance();
const isConnected = await instance.connect();
if (isConnected) {
  const polygonTestnet = blockchainConnections[80001];
  await instance.addNetwork(polygonTestnet);
}

Adds a new network to your wallet (or selects the network if it was already added).

Example 3. Get ETH balance

const balance = await instance.getBalance();

Example 4. Sign a text

const signature = await instance.sign('Hi! You are signing this text.');

Keep in touch with us on: