NearFi Wallet
  • Introduction
  • App
    • Manage Assets
    • Dapp Browser
    • Import Multiple Accounts
    • Access Key Management
    • Address Book
  • Developer Guide
    • Integrate NearFi Dapp browser into your app
      • Detecting NearFi wallet provider ready
      • Sign-in & sign-out with NearFi
      • Getting account information
      • Send transactions
      • Events
      • Wallet selector
  • Terms and Condition
  • Privacy
  • Support
Powered by GitBook
On this page
  • Signing in
  • Signing out
  1. Developer Guide
  2. Integrate NearFi Dapp browser into your app

Sign-in & sign-out with NearFi

Request NearFi user wallet to sign-in your application

PreviousDetecting NearFi wallet provider readyNextGetting account information

Last updated 2 years ago

Signing in

Once NearFi wallet object is available (see ), it is recommended for applications to request approval from users to sign-in the applications. Example code to request sign-in:

//request permission to call any function of your contract application 
const signInResponse = await window.nearFiWallet.requestSignIn({
  contractId: "your-contract-id", // the contract Id of your application
});
if (signInResponse.error) {
  console.log("failed to sign-in")
} else {
  console.log("sign-in success")
}

//you can also use promise to request
window.nearFiWallet.requestSignin({
  contractId: "your-contract-id", // the contract Id of your application
}).then(signInResponse => {})

// Or add `methodNames` if your contract application only needs permission for some of the methods
await window.nearFiWallet.requestSignIn({
  contractId: "your-contract-id", // the contract Id of your application
  methodNames: ["method1", "method2"]       // (optional) changed methods the app allowed to use
});

Signing out

API signOut serve the function of singing out when a user wants to disconnect the wallet from the applications.

await window.nearFiWallet.signOut();

The response of requestSignIn function also has an access key information. More details on the response can be found . Once successfully signed in, function window.nearFiWallet.isSignedIn() will return true.

here
here