near-api-js
near-api-js copied to clipboard
How to make trigger a popup of a browser-based wallet?
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?
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.
Will a special parameter have to be provided to an authentication request which will allow coins to be transfered?
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.