Awesome
SchnorrSnap
Quick Start
yarn install && yarn build:all && yarn demo:local
Example code,
In packages/example/frontend/Intro.tsx
import { initiateSchnorrSnap } from "./services/metamask"
import { SnapIdentity } from "@astrox/schnorr-adapter"
import { SignRawMessageResponse } from "@astrox/schnorr-types"
...
const [snapIdentity, setSnapIdentity] = useState<SnapIdentity | undefined>(
undefined,
)
const installSnap = useCallback(async () => {
// you can customize initiateSchnorrSnap with your function, hooks, or service what ever
// pass network type `mainnet`, `local`, or `nostr`
// coinType in derived path will be different, mainnet and local will be 0, nostr will be 1237 (NIP-06)
const installResult = await initiateSchnorrSnap("nostr")
if (!installResult.isSnapInstalled) {
setInstalled(false)
} else {
setInstalled(true)
setSnapIdentity(await installResult.snap?.createSnapIdentity())
}
}, [])
const getPublicKey = async () => {
setPublicKey(snapIdentity?.publicKey)
}
const signMessage = async () => {
const signed = await snapIdentity?.api.sign(message!)
setSignedMessage(signed!)
}
...
Components and install instructions
-
Download Metamask Flask and uninstall/disable old metamask
-
Go to example page or any supported page, install SchnorrSnap before run
-
Can sign message afterwards
How it works
- Develope Metamask Flask Snap project
- Use Secp256k1Key(Schnorr) identity inside snap
- Get identity and signing method for web app
Use cases
- Use Metamask as your schnorr wallet
- Access NoStr