Response Body (application/json):
{
"data": {
"id": "string (UUID)",
"algorithm": "string (e.g., ECDSA_SHA_256)",
"publicKey": "string (base64 encoded)",
"createDate": "string (ISO 8601 datetime)"
}
}
```
--------------------------------
### API Flow for User Initialization and Web3 Wallet Creation
Source: https://developers.circle.com/w3s/developer-controlled-wallets/authentication-methods
Outlines the steps to initialize an onboarded user and create a Web3 wallet. It involves an API call to initialize the user, followed by a client-side SDK operation to create the wallet using the challenge ID.
```APIDOC
1. To initialize the user, you send a POST request to the /user/initialize endpoint with userToken included in the request body.
2. Circle returns challengeId in the response.
3. You create a Web3 wallet for your user by passing challengeId to the client-side SDK for execution.
```
--------------------------------
### Example Response Body: Wallet Creation Confirmation
Source: https://developers.circle.com/w3s/developer-controlled-wallets/onboard-users-to-developer-controlled-wallets
A sample JSON response body confirming the successful creation of new wallets. It provides details for each newly created wallet, including its unique ID, current state, associated wallet set, custody type, address, blockchain, and timestamps.
```JSON
{
"data": {
"wallets": [
{
"id": "66b67097-307e-5b46-a1d5-0b1577d67fd4",
"state": "LIVE",
"walletSetId": "018b42d2-cc38-7a1e-a47a-5927d2c97f16",
"custodyType": "DEVELOPER",
"address": "0xe55628c98f5d81daaa79b72899b38a3535d10990",
"blockchain": "MATIC-AMOY",
"accountType": "SCA",
"updateDate": "2024-01-22T22:57:20Z",
"createDate": "2024-01-22T22:57:20Z"
},
{
"id": "cda61d8d-7d46-5a39-a8a6-6b4a3d6fdac3",
"state": "LIVE",
"walletSetId": "018b42d2-cc38-7a1e-a47a-5927d2c97f16",
"custodyType": "DEVELOPER",
"address": "0x29b27e792b8b854e48e85ab4f456cf5a9f1579fb",
"blockchain": "MATIC-AMOY",
"accountType": "SCA",
"updateDate": "2024-01-22T22:57:20Z",
"createDate": "2024-01-22T22:57:20Z"
}
]
}
}
```
--------------------------------
### Create Circle Smart Account and Bundler Client (WebSDK)
Source: https://developers.circle.com/w3s/developer-controlled-wallets/modular-wallets-quickstart
Illustrates the creation of a Circle Smart Account linked to a WebAuthn credential and the initialization of a bundler client. The bundler client is essential for sending user operations on the specified blockchain.
```JavaScript
import { toCircleSmartAccount } from '@circle-fin/modular-wallets-core'
import {
createBundlerClient,
toWebAuthnAccount,
} from 'viem/account-abstraction'
// 4. create a circle smart account
const smartAccount = await toCircleSmartAccount({
client,
owner: toWebAuthnAccount({
credential,
}),
})
// 5. create a bundler client
const bundlerClient = createBundlerClient({
smartAccount,
chain: polygonAmoy,
transport: modularTransport,
})
```
--------------------------------
### Example Response for Listing Wallets
Source: https://developers.circle.com/w3s/developer-controlled-wallets/developer-controlled-receive-an-inbound-transfer
This JSON object represents a typical successful response from the `GET /wallets` API call. It provides details for a single wallet, including its unique `id`, `state`, `address`, `blockchain`, and `custodyType`, which are essential for identifying and interacting with the wallet.
```JSON
{
"data": {
"wallets": [
{
"id": "ce714f5b-0d8e-4062-9454-61aa1154869b",
"state": "LIVE",
"walletSetId": "0189bc61-7fe4-70f3-8a1b-0d14426397cb",
"custodyType": "DEVELOPER",
"address": "0xf5c83e5fede8456929d0f90e8c541dcac3d63835",
"blockchain": "MATIC-AMOY",
"accountType": "SCA",
"updateDate": "2023-08-03T19:33:14Z",
"createDate": "2023-08-03T19:33:14Z"
}
]
}
}
```
--------------------------------
### React.js W3S SDK Integration Example
Source: https://developers.circle.com/w3s/developer-controlled-wallets/web
This React.js component demonstrates how to initialize the W3SSdk, configure app settings and authentication, and execute a challenge. It includes state management for configuration parameters and uses `react-toastify` for displaying success or error messages.
```JavaScript
import React, { useCallback, useEffect, useState } from 'react'
import { ToastContainer, toast } from 'react-toastify'
import TextField from '@mui/material/TextField'
import Button from '@mui/material/Button'
import { W3SSdk } from '@circle-fin/w3s-pw-web-sdk'
let sdk: W3SSdk
function App() {
useEffect(() => {
sdk = new W3SSdk({
configs: {
appSettings: { appId: 'someAppId' },
authentication: {
userToken: 'someUserToken',
encryptionKey: 'someEncryptionKey'
},
socialLoginConfig: {}
},
socialLoginCompleteCallback: (error, result) => {
if (error) {
toast.error(`Social Login Error: ${error.message ?? 'Error!'}`)
return
}
toast.success(`Social Login Success: ${result?.userToken}`)
}
})
}, [])
const [appId, setAppId] = useState(localStorage.getItem('appId') || 'someAppId')
const [userToken, setUserToken] = useState(localStorage.getItem('userToken') || 'someUserToken')
const [encryptionKey, setEncryptionKey] = useState(localStorage.getItem('encryptionKey') || 'someEncryptionKey')
const [challengeId, setChallengeId] = useState(localStorage.getItem('challengeId') || 'someChallengeId')
const onChangeHandler = useCallback(
(setState, key) => (e) => {
const value = e.target.value
setState(value)
localStorage.setItem(key, value)
},
[]
)
const onSubmit = useCallback(() => {
sdk.setAppSettings({ appId })
sdk.setAuthentication({ userToken, encryptionKey })
sdk.execute(challengeId, (error, result) => {
if (error) {
toast.error(`Error: ${error?.message ?? 'Error!'}`)
return
}
toast.success(`Challenge: ${result?.type}, Status: ${result?.status}`)
})
}, [appId, userToken, encryptionKey, challengeId])
return (
#1A1A1A
#3D3D3D
#136FD8
#B3136FD8
```
--------------------------------
### Example Response Body: List Wallets
Source: https://developers.circle.com/w3s/developer-controlled-wallets/onboard-users-to-developer-controlled-wallets
A sample JSON response body showing the structure of data returned when querying for a list of wallets. It includes details such as wallet ID, state, wallet set ID, custody type, address, blockchain, and creation/update dates.
```JSON
{
"data": {
"wallets": [
{
"id": "66b67097-307e-5b46-a1d5-0b1577d67fd4",
"state": "LIVE",
"walletSetId": "018b42d2-cc38-7a1e-a47a-5927d2c97f16",
"custodyType": "DEVELOPER",
"refId": "UUID1",
"name": "User Wallet1",
"address": "0xe55628c98f5d81daaa79b72899b38a3535d10990",
"blockchain": "MATIC-AMOY",
"accountType": "SCA",
"updateDate": "2024-01-22T22:57:20Z",
"createDate": "2024-01-22T22:57:20Z"
},
{
"id": "cda61d8d-7d46-5a39-a8a6-6b4a3d6fdac3",
"state": "LIVE",
"walletSetId": "018b42d2-cc38-7a1e-a47a-5927d2c97f16",
"custodyType": "DEVELOPER",
"refId": "UUID2",
"name": "User Wallet1",
"address": "0x29b27e792b8b854e48e85ab4f456cf5a9f1579fb",
"blockchain": "MATIC-AMOY",
"accountType": "SCA",
"updateDate": "2024-01-22T22:57:20Z",
"createDate": "2024-01-22T22:57:20Z"
}
]
}
}
```
--------------------------------
### Generate Test Ethereum Wallet Address
Source: https://developers.circle.com/w3s/developer-controlled-wallets/tx-screening-quickstart
To simulate a real screening scenario, this example provides a test Ethereum wallet address ending in '9999'. This specific suffix is designed to trigger Circle's Sanctions Blocklist in the screening API for demonstration purposes.
```Text
0x7fb49965753A9eC3646fd5d004ee5AeD6Cc89999
```
--------------------------------
### Documenting Viem Public Client Actions
Source: https://developers.circle.com/w3s/developer-controlled-wallets/modular-wallets-web-sdk
This section outlines the key actions supported by the Viem Public Client, including retrieving block and transaction information, checking balances, executing contract calls, sending transactions, and verifying messages.
```APIDOC
Public Client Actions:
getBlock: Retrieves information about a block using its number, hash, or a specific tag.
getTransaction: Fetches details of a transaction using its hash.
getBalance: Returns the balance of the specified address.
call: Executes a "call" to a contract function and retrieves the result without modifying the blockchain state.
sendTransaction: Submits a signed transaction to the blockchain network for processing.
verifyMessage: Confirms whether a given message was signed by the specified address.
```
--------------------------------
### Estimate Gas Fees for Recovery Address Registration in TypeScript
Source: https://developers.circle.com/w3s/developer-controlled-wallets/how-to-recover-passkey
This TypeScript example shows how to estimate the gas fees required for registering a recovery address. It uses `recoveryClient.estimateRegisterRecoveryAddressGas` to get an estimate, then calculates the total cost in ETH for display to the user, promoting transparency.
```TypeScript
const registerGasEstimate =
await recoveryClient.estimateRegisterRecoveryAddressGas({
account,
recoveryAddress: recoveryEoa.address,
})
const costInEth = formatEther(
registerGasEstimate.totalGas * registerGasEstimate.maxFeePerGas,
)
// Display cost to user
console.log(`Estimated cost: ${costInEth} ETH`)
```
--------------------------------
### Configure Maven Repository for Android SDK (Gradle)
Source: https://developers.circle.com/w3s/developer-controlled-wallets/modular-wallets-quickstart
This Gradle snippet configures a Maven repository within your Android project's `build.gradle` file. It dynamically loads the repository URL and credentials from a `local.properties` file, which is necessary to fetch the Modular Wallets Android SDK dependencies.
```Gradle
repositories {
...
maven {
Properties properties = new Properties()
// Load local.properties.
properties.load(new File(rootDir.absolutePath + "/local.properties").newDataInputStream())
url properties.getProperty('mwsdk.maven.url')
credentials {
username properties.getProperty('mwsdk.maven.username')
password properties.getProperty('mwsdk.maven.password')
}
}
}
```
--------------------------------
### Customize Android Dimension Resources
Source: https://developers.circle.com/w3s/developer-controlled-wallets/android
Example of customizing dimension resources in Android's `dimens.xml` file. This file is used to define standard sizes for UI elements such as margins, padding, and text sizes, aiding in responsive design and consistent layouts across different screen densities.
```XML
10dp
24dp
48dp
```