0.2.0 • Published 3 months ago

@sovereign-sdk/metamask-snap v0.2.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

Sovereign Universal MetaMask Snap

npm version Main yarn

A universal MetaMask Snap for interacting with Sovereign SDK rollups. This snap provides secure key management and transaction signing capabilities for Sovereign rollup applications.

This repository contains the snap implementation that is installed in the MetaMask snap store.

Having a universal snap allows Sovereign SDK applications to be compatible with all Sovereign SDK rollups removing the need for developers to implement and audit their own snap.

Features

  • 🔐 Secure key derivation and management
  • 📝 Verifiable human-readable transaction data display (No blind signing!)
  • ✍️ Transaction signing for multiple curves (ed25519, secp256k1)
  • 🔍 Schema validation for transaction safety
  • 🔄 Seamless integration with Sovereign SDK applications

Usage

The snap is typically used through the @sovereign-sdk/signers package, which provides a convenient interface for interacting with the snap:

import { newMetaMaskSnapSigner } from '@sovereign-sdk/signers';

const signer = newMetaMaskSnapSigner({
  curve: 'ed25519',
  schema: yourSchema,
  snapId: 'local:http://localhost:8080', // Local snap id for development, run `yarn start` to serve a local version of the snap
});
// Get public key
const publicKey = await signer.publicKey();
// Sign a transaction
const signature = await signer.sign(message);

Development

Prerequisites

Setup

# Install dependencies
yarn install

Available Commands

  • yarn build - Build the snap for production
  • yarn start - Start development server for local testing
  • yarn test - Run test suite
  • yarn lint - Run linting
  • yarn lint:fix - Fix linting and formatting issues
  • yarn clean - Clean build artifacts

See the DEVELOPMENT.md file for more information on how to develop on the snap.

Snap Manifest

The snap manifest (snap.manifest.json) is a crucial configuration file that defines the snap's properties and permissions. Key configurations include:

  • version: The snap's version number. This must match the version in the package.json file. Should be automatically managed via CI/CD pipeline.
  • proposedName: The name shown to users in MetaMask
  • description: A brief description of the snap
  • source: The entry point of the snap
  • initialPermissions: Required permissions for the snap to function:
    • snap_dialog: For displaying transaction information
    • snap_getBip32Entropy: For key derivation
    • endowment:webassembly: For running the snap's WebAssembly code. Required for universal wallet wasm support.

Security

For security concerns, please open an issue or contact us directly. We take security issues seriously and will respond promptly.