CoreCapsule Class

The CapsuleCore class provides the core Javascript implementation of the Capsule SDK, managing wallet operations, authentication, and transactions.

Properties

version
string | undefined

Static version of the CoreCapsule class.

ctx
Ctx

Context object for the CoreCapsule instance.

currentWalletIds
CurrentWalletIds

The IDs of the currently active wallets, for each supported wallet type.

wallets
Record<string, Wallet>

Wallets associated with the CoreCapsule instance.

currentExternalWalletAddresses
string[] | undefined

The addresses of the currently active external wallets.

externalWallets
Record<string, Wallet>

External wallets associated with the CoreCapsule instance.

isMultiWallet
boolean

Whether the instance has multiple wallets connected.

emailTheme
EmailTheme | undefined

Base theme for the emails sent from this Capsule instance.

emailPrimaryColor
string | undefined

Hex color to use as the primary color in the emails.

linkedinUrl
string | undefined

Linkedin URL to link to in the emails.

githubUrl
string | undefined

Github URL to link to in the emails.

xUrl
string | undefined

X (Twitter) URL to link to in the emails.

supportUrl
string | undefined

Support URL to link to in the emails.

homepageUrl
string | undefined

URL for your home landing page.

loginEncryptionKeyPair
pkiType.rsa.KeyPair | undefined

Encryption key pair generated from loginEncryptionKey.

portalTheme
Theme | undefined

Theme to use for the portal.

supportedWalletTypes
SupportedWalletTypes

Types of wallets supported by this CoreCapsule instance.

Methods

constructor()
Function

Constructs a new CoreCapsule instance.

env
Environment

Environment to use.

apiKey
string

API key to use.

opts
ConstructorOpts

Additional constructor options.

init()
Function

Initialize storage relating to a CoreCapsule instance.

setEmail()
Function

Sets the email associated with the CoreCapsule instance.

email
string

Email to set.

setPhoneNumber()
Function

Sets the phone number associated with the CoreCapsule instance.

phone
string

Phone number to set.

countryCode
CountryCallingCode

Country Code to set.

createUser()
Function

Creates a new user.

email
string

Email to use for creating the user.

verifyEmail()
Function

Passes the email code obtained from the user for verification.

verificationCode
string

Verification code to verify.

isFullyLoggedIn()
Function

Checks if a session is active and a wallet exists.

createWalletPerType()
Function

Creates several new wallets with the desired types.

skipDistribute
boolean

If true, the wallets’ recovery share will not be distributed.

types
WalletType[]

The types of wallets to create.

signMessage()
Function

Signs a message.

walletId
string

ID of the wallet to sign with.

messageBase64
string

Base64 encoding of exact message that should be signed.

signTransaction()
Function

Signs a transaction.

walletId
string

ID of the wallet to sign the transaction from.

rlpEncodedTxBase64
string

RLP encoded tx as base64 string.

chainId
string

Chain ID of the chain the transaction is being sent on.

logout()
Function

Logs the user out.

preservePregenWallets
boolean

Preserves the stored pregen wallets in memory after the logout.