@sovereign-sdk/metamask-snap
v0.1.5
Published
Sovereign SDK universal snap, compitible with all Sovereign SDK built rollups.
Downloads
146
Readme
Sovereign Universal MetaMask Snap
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
- Node.js LTS
- yarn
- MetaMask Flask (for local development)
Setup
# Install dependencies
yarn install
Available Commands
yarn build
- Build the snap for productionyarn start
- Start development server for local testingyarn test
- Run test suiteyarn lint
- Run lintingyarn lint:fix
- Fix linting and formatting issuesyarn 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 MetaMaskdescription
: A brief description of the snapsource
: The entry point of the snapinitialPermissions
: Required permissions for the snap to function:snap_dialog
: For displaying transaction informationsnap_getBip32Entropy
: For key derivationendowment: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.