Note: The Web and Mobile SDKs preserve the user keyshare with the
individual, giving them complete control. You must use the SDKs with the
user-controlled wallet product. Additionally, the Web and Mobile SDKs support
only the user-controlled wallet product.
Install the SDKs
The Android SDK supports Android API level 21+. Earlier versions are not supported.Maven (recommended)
Add the maven repository to your gradle file. It’s suggested that load settings fromlocal.properties:
Gradle
local.properties file:
Gradle
Gradle
Manual
You can also manually set up the Android SDK by downloading it from GitHub: circlefin/w3s-android-sdk.SDK architecture
You must use Web, iOS, or Android SDKs to access the user-controlled Programmable Wallet product. The SDK secures, manages, and communicates with your server to ensure your user’s keyshare, always stays with them and is not exposed to your servers. To learn more, see SDK Architecture for User-Controlled Wallets.SDK API references
WalletSdk
object WalletSdk
| Public Methods | |
|---|---|
| @Throws(Throwable::class) Unit | init(context: Context?, config: WalletSdk.Configuration?) Configure the Circle endpoint for SDK to connect, throw Throwable if the parameters are null or endpoint and appId’s format are invalid. |
| Unit | setLayoutProvider(provider: LayoutProvider?) Set a LayoutProvider derived class for customization, e.g. error code message, font and color. Ignore when the parameter is null. |
| Unit | setViewSetterProvider(provider: ViewSetterProvider?) Set a ViewSetterProvider derived class for image customization. |
| @Throws(Throwable::class) Unit | setSecurityQuestions(questions: Array<SecurityQuestion?>?) Set the security question list, throw Throwable when the SecurityQuestion array is empty or contains any question whose title length is not between 2 and 512. |
| Unit | execute(activity: Activity?, userToken: String?, encryptionKey: String?, challengeId: Array<String?>?, callback: Callback<ExecuteResult>?) Execute the operations by challengeId and call the callback after sending the request to Circle endpoint. Ignore when callback is null. Callback will receive onError() when parameters are null or invalid. |
| Unit | performLogin(activity: Activity?, provider: SocialProvider, deviceToken: String, deviceEncryptionKey: String, callback: SocialCallback<LoginResult>?) Execute Social provider login flow to get userToken, encryptionKey, refreshToken and OAuthInfo object |
| Unit | verifyOTP( activity: Activity?, otpToken: String, deviceToken: String, deviceEncryptionKey: String, callback: Callback2<LoginResult>?) Prompt OTP input UI to verify email OTP, then get userToken, encryptionKey, and refreshToken |
| Unit | performLogout(activity: Activity?, provider: SocialProvider, callback: LogoutCallback?) Clean login data, includes provider’s data and userSecret |
| String | getDeviceId(context: Context?) Extract device id. |
| Unit | addEventListener(listener: EventListener?) Register an EventListener for the app to handle events, e.g. forgot PIN. Ignore when the parameter is null. |
| Unit | removeEventListener(listener: EventListener?) Unregister an EventListener. Ignore when the parameter is null. |
| Unit | moveTaskToFront(context: Context?) Bring the SDK UI to foreground. If the app launches another Activity in onEven() and onError() and makes the SDK UI in background, use this API to go back to the SDK UI. Ignore when the parameter is null. |
| Unit | setBiometricsPin(activity: Activity?, userToken: String?, encryptionKey: String?, callback: Callback<ExecuteResult>?) Setup BiometricsForPin and call the callback after operation. Ignore when callback is null. Callback will receive onError() when parameters are null or invalid. |
| Unit | setCustomUserAgent(userAgent: String?) Set custom user agent value. Ignore when the parameter is null. |
| String | sdkVersion() Get SDK version. |
EventListener
EventListener interface that receives events when an event is triggered.interface EventListener
| Public Methods | |
|---|---|
| abstract Unit | onEvent(event: ExecuteEvent) Called when the event triggered. |
ExecuteEvent
ExecuteEvent, see WalletSdk.addEventListener().enum ExecuteEvent
| Enum values |
|---|
| forgotPin |
| resendOtp |
SocialProvider
To specify a specific Social provider to operate on. See WalletSdk.performLogin() and WalletSdk.performLogout().enum SocialProvider
| Enum values |
|---|
| Apple |
LoginResult
LoginResult for Social login.data class LoginResult
| Constructors |
|---|
constructor(userToken: String?, encryptionKey: String?, refreshToken: String?, oauthInfo: OauthInfo?) Data structure to contain results after social login. |
OauthInfo
OauthInfo for Social login.data class OauthInfo
| Constructors |
|---|
constructor(provider: String?, scope: Array<String>?, socialUserUUID: String?, socialUserInfo: SocialUserInfo?) Data structure to contain relative Oauth information of social login. |
SocialUserInfo
SocialUserInfo for Social login.data class SocialUserInfo
| Constructors |
|---|
constructor(name: String?, email: String?, phone: String?) Data structure to contain relative user information of social login. |
WalletSdk.Configuration
SDK Configuration for WalletSdk init.data class Configuration
| Constructors |
|---|
constructor(endPoint: String?, appId: String?) Init with Circle endpoint. SDK will connect to this endpoint. |
constructor(endpoint: String?, appId: String?, settingsManagement: SettingsManagement?) Init with Circle endpoint. SDK will connect to this endpoint. The SettingsManagement can bring extra setting flags to use. |
SettingsManagement
SettingsManagement is used to bring extra setting flags to Configuration that would be used when initial WalletSdk.data class SettingsManagement
| Constructors |
|---|
constructor(isEnableBiometricsPin: Boolean = false) |
| Properties | |
|---|---|
| Boolean | isEnableBiometricsPin Flag that decides whether to use biometrics to protect PIN or not. |
LayoutProvider
LayoutProvider helps perform customization during runtime.open class LayoutProvider
| Public Methods | |
|---|---|
| open TextConfig? | getTextConfig(key: String) Define strings with specific configurations for general string customization. Returned TextConfig will replace strings.xml, colors.xml, and styles.xml values. All keys are listed in C Index Table. |
| open Array<IconTextConfig?>? | getIconTextConfigs(key: Resource.IconTextsKey) Define icon and string sets with specific configurations for icon text list item customization. All keys are listed in B Index Table. |
| open Array<TextConfig?>? | getTextConfigs(key: Resource.TextsKey) Define strings with specific configurations for special text customization. All keys are listed in A Index Table. |
| open String? | getErrorString(code: ApiError.ErrorCode) Define the error description. All error codes are listed in ApiError.ErrorCode. |
| open String? | getDateFormat() Get display date format, e.g. the answer of a security question in which inputType is datePicker. Only those 3 strings are valid values: 1. “YYYY-MM-DD”, 2. “DD/MM/YYYY” 3. “MM/DD/YYYY” If it returns an invalid value, the default value would be “YYYY-MM-DD”.All supported formats are listed Resource.DateFormat. |
| open Boolean | isDebugging() true: default value, check returned value, and print warn level log false: skip checking and turn off the log. |
Resource.DateFormat
interface DateFormat
| Constants | |
|---|---|
| String | YYYYMMDD_HYPHEN = "YYYY-MM-DD" DDMMYYYY_SLASH = "DD/MM/YYYY" MMDDYYYY_SLASH = "MM/DD/YYYY" Available values of LayoutProvider.getDateFormat(). |
Resource.Key
interface Key
| Static Fields | |
|---|---|
| String | circlepw_show_pin = "circlepw_show_pin" circlepw_hide_pin = "circlepw_hide_pin" … |
TextConfig
Data class for text customization.data class TextConfig
| Constructors |
|---|
constructor(text: String?, gradientColors: IntArray?, font: Typeface?) |
constructor(text: String?, textColor: Int, font: Typeface?) |
constructor(text: String?) |
| Properties | |
|---|---|
| String? | text Text to display. |
| @CorlorInt IntArray? | gradientColors Array of Gradient text color. Only used by TextsKey.enterPinCodeHeadline, TextsKey.securityIntroHeadline, TextsKey.newPinCodeHeadline |
| @CorlorInt IntArray? | textColor Text color. |
| Typeface? | font Font. |
IconTextConfig
Data class for icon text list item customization.data class IconTextConfig
| Constructors |
|---|
constructor(setter: IImageViewSetter?, textConfig: TextConfig?) |
| Properties | |
|---|---|
| IImageViewSetter? | setter The ImageView setter for image customization. |
| TextConfig? | textConfig Text config for text customization. |
Resource.TextsKey
enum TextsKey
| Enum Values |
|---|
| securityQuestionHeaders |
| securitySummaryQuestionHeaders |
| enterPinCodeHeadline |
| securityIntroHeadline |
| newPinCodeHeadline |
| securityIntroLink |
| recoverPinCodeHeadline |
Resource.IconTextsKey
enum IconTextsKey
| Enum Constants |
|---|
| securityConfirmationItems |
IImageViewSetter
The ImageView setter interface for image customization.interface IImageViewSetter
| Public Methods | |
|---|---|
| abstract Unit | apply(iv: ImageView? ) Called when the ImageView needs to be set. |
LocalImageSetter
The implemented ImageView setter for image customization with local image.class LocalImageSetter: IImageViewSetter
| Constructors |
|---|
constructor(drawableId: Int) |
| Properties | |
|---|---|
| @DrawableRes Int | drawableId The resource ID of drawable. |
| Public Methods | |
|---|---|
| Unit | apply(iv: ImageView) Set drawable to the imageView with drawableId. |
RemoteImageSetter
The implemented ImageView setter for image customization with a remote image.class RemoteImageSetter: IImageViewSetter
| Constructors |
|---|
constructor(drawableId: Int) |
constructor(drawableId: Int, url: String?) |
| Properties | |
|---|---|
| @DrawableRes Int | drawableId The resource ID of drawable. |
| String | url Image URL. |
| Public Methods | |
|---|---|
| Unit | apply(iv: ImageView) Set a remote image from the URL to the ImageView. Use the drawable as the placeholder. |
IToolbarSetter
The Toolbar setter interface for image customization.interface IToolbarSetter
| Public Methods | |
|---|---|
| abstract Unit | apply(toolbar: Toolbar?) Called when the Toolbar needs to be set. |
LocalToolbarImageSetter
class LocalToolbarImageSetter: IToolbarSetter
| Constructors |
|---|
constructor(drawableId: Int) |
| Properties | |
|---|---|
| @DrawableRes Int | drawableId The resource ID of drawable. |
| Public Methods | |
|---|---|
| Unit | apply(toolbar: Toolbar?) Set drawable as navigation icon to the Toolbar. |
RemoteToolbarImageSetter
The implemented Toolbar setter for image customization with a remote image.class RemoteToolbarImageSetter: IToolbarSetter
| Constructors |
|---|
constructor(drawableId: Int) |
constructor(drawableId: Int, url: String?) |
| Properties | |
|---|---|
| @DrawableRes Int | drawableId The resource ID of drawable. |
| String? | url Image URL. |
| Public Methods | |
|---|---|
| Unit | apply(toolbar: Toolbar?) Set a remote image from the URL to the toolbar. Use drawable as the placeholder. |
ViewSetterProvider
ViewSetterProvider supports performing image customization during runtime.open class ViewSetterProvider extends Object
| Public Methods | |
|---|---|
| open IImageViewSetter? | getImageSetter(type: Resource.Icon) Return implemented IImageViewSetter for performing general image customization. e.g. LocalImageSetter, RemoteImageSetter All keys are listed in D Index Table. |
| open IToolbarSetter? | getToolbarImageSetter( <br /> type: Resource.ToolbarIcon <br />) Return implemented IToolbarSetter for performing Toolbar image customization. e.g. LocalToolbarImageSetter, RemoteToolbarImageSetter All keys are listed in E Index Table. |
Resource.Icon
enum Icon
| Enum Values |
|---|
| securityIntroMain |
| selectCheckMark |
| dropdownArrow |
| errorInfo |
| securityConfirmMain |
| biometricsAllowMain |
| showPin |
| hidePin |
| alertWindowIcon |
| swipeItemIcon |
| swipeBtConfirmed |
| transactionTokenIcon |
| networkFeeTipIcon |
| requestIcon |
| showLessDetailArrow |
| showMoreDetailArrow |
Resource.ToolbarIcon
enum ToolbarIcon
| Enum Values |
|---|
| close |
| back |
SecurityQuestion
Data class for security questions customization. See WalletSdk.setSecurityQuestions().data class SecurityQuestion
| Constructors |
|---|
| constructor(title: String) |
| constructor(title: String, inputType: SecurityQuestion.InputType) |
| Properties | |
|---|---|
| String | title The question string. |
| SecurityQuestion.InputType | inputType The input type of the question. Support text input and timePicker. |
SecurityQuestion.InputType
public enum InputType
| Enum Values |
|---|
| text |
| datePicker |
Callback
A generic callback interface for SDK API callsinterface Callback<R>
| Public Methods | |
|---|---|
| abstract Boolean | onError(error: Throwable) The callback is triggered when a failure occurs in operation or is canceled by the user. Return true - The app will handle the following step, SDK will keep the Activity. Return false - The app won’t handle the following step, SDK will finish the Activity. |
| abstract Unit | onResult(result: R) R - Type of result such as ExecuteResult Callback when the operation is executed successfully. Finish the Activity after this callback is triggered. |
| abstract Boolean | onWarning(warning: ExecuteWarning, result: R?) The callback is triggered when operation executed with warning. R - Type of result such as ExecuteResult Return true - App will handle the following step, SDK will keep the Activity. Return false - App won’t handle the following step, SDK will finish the Activity. |
Callback2
The callback interface for verifyOTP()interface Callback2<R>
| Public Methods | |
|---|---|
| abstract Boolean | onError(error: Throwable) The callback is triggered when a failure occurs in operation or is canceled by the user. Return true - The app will handle the following step, SDK will keep the Activity. Return false - The app won’t handle the following step, SDK will finish the Activity. |
| abstract Unit | onResult(result: R) R - Type of result such as ExecuteResult Callback when the operation is executed successfully. Finish the Activity after this callback is triggered. |
SocialCallback
The callback interface for performLogin()interface SocialCallback<R>
| Public Methods | |
|---|---|
| abstract Unit | onError(error: Throwable) The callback is triggered when a failure occurs in operation or is canceled by the user. |
| abstract Unit | onResult(result: R) R - Type of result such as ExecuteResult Callback when the operation is executed successfully. Finish the Activity after this callback is triggered. |
LogoutCallback
The callback interface for performLogout()interface LogoutCallback
| Public Methods | |
|---|---|
| abstract Unit | onError(error: Throwable) The callback is triggered when a failure occurs in operation or is canceled by the user. |
| abstract Unit | onComplete() Callback when social logout operation completed. |
ExecuteWarning
enum ExcuteWarning
| Properties | |
|---|---|
| Int | warningType Warning type. |
| String | warningString Description of the warning type. |
| Enum Values |
|---|
| biometricsUserSkip(155711, “User skipped the setting of using biometrics to protect PIN this time.”) |
| biometricsUserDisableForPin(155712, “User disabled the function of using biometrics to protect PIN.”) |
| biometricsUserLockout(155713, “Too many attempts. Try again later.”) |
| biometricsUserLockoutPermanent(155714, “Too many attempts. Biometrics sensor disabled.”) |
| biometricsUserNotAllowPermission(155715, “User didn’t grant the permission to use biometrics”), //IOS ONLY |
| biometricsInternalError(155716, “Biometrics internal error - %s”); |
ExecuteResult
data class ExecuteResult
| Constructors |
|---|
constructor( resultType: ExecuteResultType, status: ExecuteResultStatus, data: ExecuteResultData = ExecuteResultData() ) |
| Properties | |
|---|---|
| ExecuteResultType | resultType The type of the operation that the challenge represents. The possible values are : UNKNOWN(-1), SET_PIN(0), RESTORE_PIN(1), CHANGE_PIN(2), SET_SECURITY_QUESTIONS(3), CREATE_WALLET(4), CREATE_TRANSACTION(5), ACCELERATE_TRANSACTION(6), CANCEL_TRANSACTION(7), CONTRACT_EXECUTION(8), SIGN_MESSAGE(9), SIGN_TYPEDDATA(10), SIGN_TRANSACTION(11), SET_BIOMETRICS_PIN(1000) |
| ExecuteResultStatus | status The status of the execution. The possible values are : UNKNOWN(-1) PENDING(0) IN_PROGRESS(1) COMPLETE(2) FAILED(3) EXPIRED(4) |
| ExecuteResultData | data The data of the execution. |
ExecuteResultType
enum ExecuteResultType
| Properties | |
|---|---|
| Int | value The int value of the enum. |
| Enum Values |
|---|
| UNKNOWN(-1) |
| SET_PIN(0) |
| RESTORE_PIN(1) |
| CHANGE_PIN(2) |
| SET_SECURITY_QUESTIONS(3) |
| CREATE_WALLET(4) |
| CREATE_TRANSACTION(5) |
| ACCELERATE_TRANSACTION(6) |
| CANCEL_TRANSACTION(7) |
| CONTRACT_EXECUTION(8) |
| SIGN_MESSAGE(9) |
| SIGN_TYPEDDATA(10) |
| SIGN_TRANSACTION(11) |
| INITIALIZE(12) |
| WALLET_UPGRADE(13) |
| SET_BIOMETRICS_PIN(1000) |
ExecuteResultStatus
enum ExecuteResultStatus
| Properties | |
|---|---|
| Int | value The int value of the enum. |
| Enum Values |
|---|
| UNKNOWN (-1) |
| PENDING(0) |
| IN_PROGRESS(1) |
| COMPLETED(2) |
| FAILED(3) |
| EXPIRED(4) |
ExecuteResultData
data class ExecuteResultData
| Constructors |
|---|
constructor(signature: String? = null) |
| Properties | |
|---|---|
| String? | signature The signature for SIGN_MESSAGE, SIGN_TYPEDDATA and SIGN_TRANSACTION. For SIGN_TRANSACTION, the signature encodes the v, r, s parameters in big-endian format. |
| String? | signedTransaction Signed transaction string for SIGN_TRANSACTION. Will be a hex string with ‘0x’ prefix for EVM chains. |
| String? | txHash The hash of the transaction for SIGN_TRANSACTION. |
APIError
Error class for PW SDKabstract class ApiError:[Throwable](https://developer.android.com/reference/java/lang/Throwable)
| Properties | |
|---|---|
| abstract ApiError.ErrorCode | code Error code. |
| open String | message Get human-readable error message |
ApiError.ErrorCode
public enum ErrorCode
| Properties | |
|---|---|
| Int | value The int value of the enum. |
| Enum Value | Description |
|---|---|
| undefined(-1) | Used when an error is defined on the server but not in the SDK. Overrides unknown(-1) if a server-defined code exists |
| unknown(-1) | An unspecified error occurred |
| success(0) | The operation completed successfully |
| apiParameterMissing(1) | A required API parameter is missing |
| apiParameterInvalid(2) | An API parameter provided is invalid |
| forbidden(3) | The request is forbidden due to insufficient permissions |
| unauthorized(4) | Authentication failed or user is not authorized |
| retry(9) | Temporary issue; retry the operation |
| customerSuspended(10) | The customer’s account is suspended |
| pending(11) | The operation is pending and not yet completed |
| invalidSession(12) | The session is invalid or has expired |
| invalidPartnerId(13) | The provided partner ID is invalid |
| invalidMessage(14) | Message format is invalid |
| invalidPhone(15) | The phone number provided is invalid |
| userAlreadyExisted(155101) | The user already exists in the system |
| userNotFound(155102) | The specified user was not found |
| userTokenNotFound(155103) | The user token was not found |
| userTokenExpired(155104) | The user token has expired |
| invalidUserToken(155105) | The user token provided is invalid |
| userWasInitialized(155106) | The user has already been initialized |
| userHasSetPin(155107) | The user has already set a PIN |
| userHasSetSecurityQuestion(155108) | The user has already set security questions |
| userWasDisabled(155109) | The user account has been disabled |
| userDoesNotSetPinYet(155110) | The user has not set a PIN yet |
| userDoesNotSetSecurityQuestionYet(155111) | The user has not set security questions yet |
| incorrectUserPin(155112) | The PIN entered is incorrect |
| incorrectDeviceId(155113) | The device ID provided is incorrect |
| incorrectAppId(155114) | The application ID provided is incorrect |
| incorrectSecurityAnswers(155115) | The security answers provided are incorrect |
| invalidChallengeId(155116) | The challenge ID provided is invalid |
| invalidApproveContent(155117) | The approval content is invalid |
| invalidEncryptionKey(155118) | The encryption key provided is invalid |
| userPinLocked(155119) | The user’s PIN is locked due to multiple failed attempts |
| securityAnswersLocked(155120) | The user’s security answers are locked due to multiple failed attempts |
| walletIsFrozen(155501) | The wallet is frozen and cannot perform operations |
| maxWalletLimitReached(155502) | The user has reached the maximum number of wallets allowed |
| walletSetIdMutuallyExclusive(155503) | The wallet set ID is mutually exclusive and cannot be used with the current operation |
| metadataUnmatched(155504) | The metadata provided does not match the expected format or values |
| userCanceled(155701) | The user canceled the operation |
| launchUiFailed(155702) | Failed to launch the user interface |
| pinCodeNotMatched(155703) | The PIN code entered does not match the expected value |
| insecurePinCode(155704) | The PIN code entered is considered insecure |
| hintsMatchAnswers(155705) | The hints provided match the security answers, which is not allowed |
| networkError(155706) | A network error occurred during the operation |
| biometricsSettingNotEnabled(155708) | Biometrics settings are not enabled on the device |
| deviceNotSupportBiometrics(155709) | The device does not support biometric authentication |
| biometricsKeyPermanentlyInvalidated(155710) | The biometric key has been permanently invalidated |
| biometricsUserSkip(155711) | The user skipped biometric authentication |
| biometricsUserDisableForPin(155712) | The user disabled biometrics for PIN authentication |
| biometricsUserLockout(155713) | The user is temporarily locked out of biometric authentication |
| biometricsUserLockoutPermanent(155714) | The user is permanently locked out of biometric authentication |
| biometricsUserNotAllowPermission(155715) | The user did not grant permission for biometric authentication |
| biometricsInternalError(155716) | An internal error occurred during biometric authentication |
| invalidUserTokenFormat(155718) | The user token format is invalid |
| userTokenMismatch(155719) | The user token does not match the expected value |
| socialLoginFailed(155720) | Social login failed |
| loginInfoMissing(155721) | Login information is missing |
| walletIdNotFound(156001) | The specified wallet ID was not found |
| tokenIdNotFound(156002) | The specified token ID was not found |
| transactionIdNotFound(156003) | The specified transaction ID was not found |
| entityCredentialNotFound(156004) | The specified entity credential was not found |
| walletSetIdNotFound(156005) | The specified wallet set ID was not found |
Static Customized String
res/values/strings.xml
XML
Static Customized UI Layout
res/values/color.xml
XML
res/values/styles.xml
XML
res/values/dimens.xml
XML
Sample Code
Java
Java
Java
Java
Java
Java