near-api-js icon indicating copy to clipboard operation
near-api-js copied to clipboard

How to make trigger a popup of a browser-based wallet?

Open GildedHonour opened this issue 2 years ago • 2 comments

I have this code in a browser:

  const { connect, keyStores, WalletConnection } = nearAPI;
  const testnetConnectionConfig = {
    networkId: "testnet",
    keyStore: new keyStores.BrowserLocalStorageKeyStore(),
    nodeUrl: "https://rpc.testnet.near.org",
    walletUrl: "https://wallet.testnet.near.org",
    helperUrl: "https://helper.testnet.near.org",
    explorerUrl: "https://explorer.testnet.near.org",
  };

  async function connectAndSignIn() {
    const testnetNearConnection = await connect(testnetConnectionConfig);
    const testnetWalletConnection = new WalletConnection(testnetNearConnection);

    //
    testnetWalletConnection.requestSignIn(
      //.......... [....]

This, however, will redirect me to https://wallet.testnet.near.org/login. But this isn't want I want.

Why won't it trigger a popup with a browser wallet, the way it'll happen with MetaMask on other websites? I have Sender wallet installed in Chromium.

More globally, I want to allow a user to send a transaction to my smart contract, with certain parameters that are unique to each user and purchase.

How to do it?

GildedHonour avatar Oct 08 '22 00:10 GildedHonour

2nd question which may make the 1st one irrelevant:

if I do use browser-based wallet instead of the one as extention, how will I allow and make a user to transfer coins to a smart contract? For during authentication there's a text which says that this type of an authentication process won't permit a user, or an application, to transfer coins from a user's wallet. Whereas this is what I need.

Screenshot_2022-10-07_21-36-44

Will a special parameter have to be provided to an authentication request which will allow coins to be transfered?

GildedHonour avatar Oct 08 '22 00:10 GildedHonour

This sounds like a duplicated of the issue I opened: https://github.com/near/near-api-js/issues/1010

I am planning on doing a PR for that on the following days / next week.

DevSlashRichie avatar Oct 10 '22 21:10 DevSlashRichie