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
Usually you will call signOut()
method to close a user session. Use disconnect()
when you want to clear the connection between the wallet and your app. Next time the user signs in with that wallet, he'll must gran connection permission again.
Send empty arguments or empty string to disconnect from currently active account. Or call disconnect with a wallet provider key to force the disconnection of a specific wallet.
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.
getAccountIdenticon
typescript
getAccountIdenticon(hex: string, size: number = 20): HTMLCanvasElement
Gets the account for the current session (if any). Or undefined
if there is no active session.
getActiveAccountAsync
Gets the account for the current session (if any). Returns undefined
if there is no active session.
Pass options.withBalance = true
to include the balance of the account.
getActivePublicKey
Gets the public key for the current session (if any). Or undefined if no active session.
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
.
The deploy
is a json object that can be passed to the send()
method as a string or as an object.
signingPublicKey
MUST be the public key for the active account. Otherwise, this method will return an error.
Example using JS SDK:
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
.
The deploy
is a json object that can be passed to the sign()
method as a string or as an object.
signingPublicKey
MUST be the public key for the active account. Otherwise, this method will return an error.
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).
Call this method without any provider to request CSPR.click UI to show the Switch Account modal window.
Last updated