Methods
connect
Call the connect()
method using a provider name as the first parameter to request a connection using that wallet or login mechanism.
Some providers may need an options argument to indicate the connection behavior requested.
disconnect
Disconnects the web application from the provider when this option is available. The application should close the user session as a result of this call.
forgetAccount
Removes an account from the list of known accounts in CSPR.click. It won’t be returned to the list of known accounts unless it’s connected again using the connect()
method.
getActiveAccount
Gets the account for the current session (if any). Or undefined
if there is no active session.
getActivePublicKey
Gets the public key for the current session (if any). Or undefined if no active session.
getKnownAccounts
Returns a list of accounts known for CSPR.click. These accounts have been used previously in you dApp or in any other dApp connected to CSPR.click.
To use any returned account to start a session in your dApp, call signInWithAccount
.
getSignInOptions
Returns an object with a list of providers enabled to use in the application and a list of known accounts that can be used to sign in automatically with signInWithAccount()
.
init
Call init
to initialize CSPR.click in your web application. This MUST be the first method you call after the downloading of the library.
See CsprClickInitOptions for reference on the options
parameter.
isConnected
Checks if the provider (not the account) indicated as the first argument is connected to the application. Note this check is independent of whether there's an active account on CSPR.click or not or even if that account belongs to the given provider.
isProviderPresent
Checks if the provider indicated as the first argument is enabled in the application and installed (in case it’s a browser extension).
isUnlocked
Returns true
if the provider is unlocked. false
if the provider is locked.
This method returns undefined
when the provider does not offer this information.
send
Triggers the mechanisms to request your user to sign a deploy with the active wallet.
When the user approves the signature, CSPR.click sends the deploy to the Casper network. A SendResult object is returned with a deployHash
value or an error
.
signingPublicKey
MUST be the public key for the active account. Otherwise, this method will return an error.
sign
Triggers the mechanisms to request your user to sign a deploy with the active wallet.
A SignResult object is returned with the signature value or an error
.
signingPublicKey
MUST be the public key for the active account. Otherwise, this method will return an error.
NOTE: sign()
method can’t be used with Torus Wallet. Use send()
instead.
signIn
Triggers a request to a UI library to show a sign-in dialog.
signInWithAccount
Starts a session with the indicated account. This account must be one of the accounts returned in getKnownAccounts
or getSignInOptions
.
Note that no interaction with the account provider is required to sign-in. CSPR.click will check and restore the connection if needed when there's a transaction or message to sign.
signMessage
Triggers the mechanisms to request your user to sign a text message with the active wallet.
signingPublicKey
MUST be the public key for the active account. Otherwise, this method will return an error.
signOut
Closes an active session in your dApp.
Triggers the csprclick:signed_out
event.
switchAccount
Call this method to request to the specified wallet to offer the user the selection of a different account. This is valid for providers with its own UI (like browser extenstions).
Last updated