Before the Galactica Snap can be installed, we need to check that Metamask is available in the user's browser. This is similar to a standard Metamask connection.
If Metamask is not installed, you can forward the user with the connect button to the install page:
/** * Get the snap from MetaMask. * * @returns The snap object returned by the extension. */exportconstgetSnap=async ():Promise<Snap|undefined> => {try {constsnaps=awaitwindow.ethereum.request({ method:'wallet_getSnaps', });returnObject.values(snaps).find( (snap) =>snap.id === defaultSnapOrigin, ); } catch (error) {console.log('Failed to obtain installed snap', error);returnundefined; }};
Now you should be able to use Galactica specific functions through the snap using the wallet_invokeSnap method. See the next page for an example