How to request permit to "wallet_invokeSnap"?

template-snap
Send Hello can’t run

My code can’t run too…

const walletInvokeSnap = async (method) => {
  try {
    const response = await ethereum.request({
      method: "wallet_invokeSnap",
      params: [
        snapId,
        {
          method,
        },
      ],
    });
    console.log(response);
  } catch (err) {
    console.error(err);
    alert("Problem happened: " + err.message || err);
  }
};

I think “wallet_invokeSnap” has no permission methods. But I don’t know how to request a permit…

I already send the issue to the Github repo.

1 Like

Hello @sinsinpurin, welcome to MetaMask community!

Have you also checked the MetaMask Snaps docs here?

3 Likes

Hi @sinsinpurin, in the snap.manifest.json file you need to request the “snap_confirm” permission. See here: template-snap/snap.manifest.json at main · MetaMask/template-snap · GitHub

But it’s possible that there is some other issue preventing your snap from running. Did you start from the snap template and modify the code? You should be able to make small modifications and see if it still works. You could also try following this tutorial:

2 Likes

@montoya
“snap_confirm” permission request has not changed the situation

it is same MetaMask example snap situation.
(I can’t post the url for some reason…)
Can you reproduce it?

this is my code

  "initialPermissions": {
    "endowment:network-access": {},
    "snap_confirm": {},
    "snap_getBip44Entropy_1": {},
    "snap_manageState": {}
  },
const connect = async () => {
  await ethereum.request({
    method: "wallet_enable",
    params: [
      {
        wallet_snap: { [snapId]: {} },
      },
    ],
  });
};

const walletInvokeSnap = async (method) => {
  try {
    const response = await ethereum.request({
      method: "wallet_invokeSnap",
      params: [
        snapId,
        {
          method,
        },
      ],
    });
    console.log(response);
  } catch (err) {
    console.error(err);
    alert("Problem happened: " + err.message || err);
  }
};
2 Likes

Sorry to hear it is still not working. If you publish your snap in a GitHub repository (free for personal projects) then I can have a better look at the code and figure out what might be the issue. I have a feeling it is just a configuration issue.

3 Likes

This is snap repo at github. (I can’t post the URL so please google)
block-base/amsterdam-starknet-hackathon

1 Like

:slight_smile:

1 Like

I think I got this situation.

I checked MetaMask snap is working fine.

Also I reproduced the issue.

I can reproduce this issue when I remove and not serving snap.manifest.json file in host.

2 Likes

Can you try this?

  1. clone MetaMask-snap template

  2. do following command
    yarn install
    yarn build ← this is also required
    yarn serve

2 Likes

And for the starknet repo (this is my previous work), that is developed almost 4-5months ago.
I think some of the changes (maybe some code, or maybe MetaMask-cli version) affected.

I used MetaMask template repo as base and moved starknet logic to MetaMask template, and it works fine.

So I suggest not using starknet one, but using MetaMask template as base.

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.