1.10.0 • Published 7 months ago

@ututrust/utu-metamask-snap v1.10.0

Weekly downloads
-
License
(Proprietary)
Repository
gitlab
Last release
7 months ago

UTU Trust Metamask Snap

UTU has built a Snap (basically a MetaMask plugin) to let you get UTU signal inside your MetaMask Wallet right at the moment when you're about to confirm a transaction.

At the moment the UTU Snap is only available in MetaMask Flask (an experimental version of MetaMask) that you can think of like a training ground for the big stage.

More information about UTU

UTU Trust SDK provides web-components that access UTU’s Trust API and allows you simple integration with its services.

Find the repository here

Install

$ npm i @ututrust/utu-metamask-snap

Example

Quickstart React

import React from 'react';

const Snap = () => {
  const getEnv = () => {
    let env = 'staging';
    if (window.location.href.includes('3000')) {
      env = 'local';
    } else if (process.env.REACT_APP_API_URL?.includes("<place-your-production-api-url>")) {
      env = 'production';
    }
    return env;
  };

  const installMetaMaskFlask = () => {
    const win = window.open('https://metamask.io/flask/', '_blank');
    win.focus();
  };

  const installSnap = async () => {
    try {
      const accessToken = await getUTUApiAccessToken(); // Replace with your logic for fetching the token

      // Request to add the UTU Snap
      await window.ethereum.request({
        method: 'wallet_requestSnaps',
        params: {
          'npm:@ututrust/utu-metamask-snap': {},
        },
      });

      const env = getEnv();

      // Authorize the UTU Snap
      await window.ethereum.request({
        method: 'wallet_invokeSnap',
        params: {
          snapId: 'npm:@ututrust/utu-metamask-snap',
          request: {
            method: 'authorizeUTUSnap',
            params: { token: accessToken, env },
          },
        },
      });
      console.log("UTU Snap installed and authorized!");
    } catch (error) {
      console.error("Error installing or authorizing the UTU Snap:", error);
    }
  };

  return (
    <div>
      <button onClick={installMetaMaskFlask}>
        Install MetaMask Flask
      </button>
      <button onClick={installSnap}>
        Install UTU Snap into MetaMask Flask
      </button>
    </div>
  );
};

export default Snap;
1.10.0

7 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.0

1 year ago