Sign in Applications in Near

Once you have Sender installed, you'll be able to sign in and interact with the applications in Near chain.

Sign In

To interact with smart contracts, users need to sign in the application and request one function call key for the contract. Once sign in, the application will be authorized to call the change methods defined in the scope.

// Sender will show a popup dialog to ask user to authorize your dApp
// This creates an access key that will be stored in Sender's storage
// The access key can then be used to connect to NEAR and sign transactions

await window.near.requestSignIn({
  contractId: "guest-book.testnet", // contract requesting access
});

// Or add `methodNames` if you only allow the key to call some of the methods

await window.near.requestSignIn({
  contractId: "guest-book.testnet", // contract requesting access
  methodNames: ["addMessage"]       // (optional) changed methods the app allowed to use
});

window.near.isSignedIn()   // true

Sign Out

You may want to remove the generated function access key from browser extension storage if you don't want to use the application any more.

// For version 1.11.7 and below
window.near.signOut();    // true
window.near.isSignedIn();   // false

// For version 2.0.0 and above
window.sender.near.signOut();    // true
window.sender.near.isSignedIn();   // false

Last updated