# CIRCLE

Circle Programmable Wallets is a Wallet as a Service that simplifies creating and managing secure web3 wallets and their private keys. They extend wallet functionality with approachable user flows, provide optionality for developer and user infrastructure solutions, and enable seamless smart contract integration.\
To use CIRCLE with expand.network [<mark style="color:blue;">**SDK**</mark>](https://github.com/expand-network/sdk-nodejs.git), follow these steps:-

### **Step 1:** Installation

&#x20;User needs to install the expand.network SDK using the following command:&#x20;

```git
npm i expand-network
```

### **Step 2: Wallet Initialisation**

```javascript
async function initcircleWallet(options){
    const userToken = await WalletCircle.getUserToken(options);
    options.userToken = userToken.userToken;
    options.encryptionKey = userToken.encryptionKey;
    const wallet = new WalletCircle(options);
    return wallet;
}
```

### **Step 3: Prepare Transaction**

```javascript
// Preparing the approve transaction from expand.network
const prepareApproveTx = await prepareTransaction('https://api.expand.network/fungibletoken/approve', {
        "from": "SENDER_ADDRESS",
        "tokenAddress": "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60",
        "to": "RECEIVER_ADDRESS",
        "amount": "10000",
        "gas": "25000",
        "xApiKey": 'YOUR_API_KEY'        //Replace with your API key
    });
```

### **Step 4: Sign Transaction**

```javascript
// Sign the transaction locally using sdk client
const signedTx = await wallet.signTransaction(prepareApproveTx);
console.log("signedTx: " ,signedTx);
```

### **Step 5: Send Transaction**

```javascript
// Send the signed transaction
const tx = await wallet.sendTransaction(signedTx);
console.log("sent tx: ", tx);
```

### Sample code to approve a fungible token using Circle:&#x20;

```javascript
const { WalletCircle, prepareTransaction } = require('expand-network');
async function initcircleWallet(options){
    const userToken = await WalletCircle.getUserToken(options);
    options.userToken = userToken.userToken;
    options.encryptionKey = userToken.encryptionKey;
    const wallet = new WalletCircle(options);
    return wallet;
}
async function main(){
    const wallet = await initcircleWallet({
        appId: "CIRCLE_APP_ID",
        apiKey: 'CIRCLE_API_KEY',
        userId: 'CIRCLE_USER_ID',
        walletId: 'CIRCLE_WALLET_ID',
        encryptionKey: 'CIRCLE_ENCRYPTION_KEY'
    });
    const prepareApproveTx = await prepareTransaction('https://api.expand.network/fungibletoken/approve', {
        "from": "SENDER_ADDRESS",
        "tokenAddress": "0xdc31Ee1784292379Fbb2964b3B9C4124D8F89C60",
        "to": "RECEIVER_ADDRESS",
        "amount": "10000",
        "gas": "25000",
        "xApiKey": 'YOUR_API_KEY'
    });
    const signedTx = await wallet.signTransaction(prepareApproveTx);
    console.log("signedTx: " ,signedTx);
    const tx = await wallet.sendTransaction(signedTx);
    console.log("sent tx: ", tx);
}
main();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.expand.network/~/changes/CwwHZ0oIeFsEWwiEWd1b/integrations/wallets/mpc-wallets/circle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
