Use the Node.js SDK to interact with Circle's Developer-Controlled Wallet APIs, which allow you to embed secure wallets in your applications and create blockchain transactions using the Developer Services platform.
This page provides short examples of how to install and use the Developer-Controlled Wallets SDK. For complete examples, see the Sample Projects page. For more information see the Developer-Controlled Wallets documentation.
To successfully use the Developer-Controlled Wallets SDK, you need the following:
Use the following commands to install the SDK. You can view the package information on the npm site.
npm install @circle-fin/developer-controlled-wallets --save
To start using the SDK, you first need to configure a client. Import the
initiateDeveloperControlledWalletsClient
factory from the SDK, and then
initialize the client using your API key and entity secret.
The following example shows how to import the client and configure it to use your API key and entity secret:
const {
initiateDeveloperControlledWalletsClient,
} = require('@circle-fin/developer-controlled-wallets')
const client = initiateDeveloperControlledWalletsClient({
apiKey: '<your-api-key>',
entitySecret: '<your-entity-secret>',
})
The following example shows how to create a wallet using the client:
const walletSetResponse = await client.createWalletSet({ name: 'WalletSet 1' })
console.log('Created WalletSet', walletSetResponse.data?.walletSet)
const walletsResponse = await client.createWallets({
blockchains: ['MATIC-AMOY'],
count: 2,
walletSetId: walletSetResponse.data?.walletSet?.id ?? '',
})
console.log('Created Wallets', walletsResponse.data?.wallets)
The following example shows how to create a transaction using the client:
const response = await client.createTransaction({
amounts: ['0.01'],
destinationAddress: '0xa51c9c604b79a0fadbfed35dd576ca1bce71da0a',
tokenId: '738c8a6d-8896-46d1-b2cb-083600c1c69b',
walletId: 'a635d679-4207-4e37-b12e-766afb9b3892',
fee: { type: 'level', config: { feeLevel: 'HIGH' } },
})
console.log(response.data)
The client for the Developer-Controlled Wallets SDK accepts the following configuration parameters:
Option | Required? | Description |
---|---|---|
apiKey | Yes | The API key used to authenticate requests to the Circle API. |
entitySecret | Yes | Your configured entity secret. |
storage | No | Optional custom storage solution for persisting data. If not provided, the SDK uses in-memory storage. |