Methods

connect

connect(provider: string, options: any): Promise<void>

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

 disconnect(): void

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

forgetAccount(account: AccountType): void

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

getActiveAccount(): AccountType | null 

Gets the account for the current session (if any). Or undefined if there is no active session.

getActiveAccountWithBalance

getActiveAccountWithBalance(): Promise<AccountType | null> 

Gets the account for the current session (if any). It also returns the balance of the account. Returns undefined if there is no active session.

getActivePublicKey

getActivePublicKey(): Promise<string | undefined>

Gets the public key for the current session (if any). Or undefined if no active session.

getKnownAccounts

getKnownAccounts(): Promise<Array<AccountType>>

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

getSignInOptions(refresh: boolean = false): Promise<any>

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

init(options: CsprClickInitOptions): void

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

isConnected(provider: string): Promise<boolean | undefined>

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

isProviderPresent(provider: string): boolean

Checks if the provider indicated as the first argument is enabled in the application and installed (in case it’s a browser extension).

isUnlocked

isUnlocked(provider: string): Promise<boolean | undefined>

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

send(deployJson: string, signingPublicKey: string): Promise<SendResult | undefined>

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

sign(deployJson: string, signingPublicKey: string): Promise<SignResult | undefined>

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

signIn(): void

Triggers a request to a UI library to show a sign-in dialog.

signInWithAccount

signInWithAccount(account: AccountType): Promise<AccountType | undefined>

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

signMessage(message: string, signingPublicKey: string): Promise<SignResult|undefined>

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

signOut(): void

Closes an active session in your dApp.

Triggers the csprclick:signed_out event.

switchAccount

switchAccount(withProvider: string | undefined, options?: any): Promise<void>

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