nillion-user-key-manager
v0.1.2
Published
A Snap for storing your Nillion User Key in MetaMask
Downloads
5
Readme
Nillion User Key Manager Snap
This is an expermental snap for storing a Nillion user key in a MetaMask snap.
Usage of the nillion-user-key-manager snap in a dapp
Use the nillion-user-key-manager snap to read the user key store in the snap
async function connectAndCallSnap() {
const nillionSnapId = 'npm:nillion-user-key-manager';
if (window.ethereum) {
try {
// Request permission to connect to the Snap.
await window.ethereum.request({
method: 'wallet_requestSnaps',
params: {
[nillionSnapId]: {},
},
});
// Call the 'read_user_key' method of the Snap using wallet_invokeSnap.
const snapResponse = await window.ethereum.request({
method: 'wallet_invokeSnap',
params: {
snapId: nillionSnapId,
request: { method: 'read_user_key' },
},
});
// Log the user key
console.log(snapResponse && snapResponse.user_key);
} catch (error) {
console.error('Error interacting with Snap:', error);
}
}
}