(smartAccount)
- smartAccountBatchedUserOperations - Get Smart Account Batched User Operations
Generate a list of user operations for smart account batching.
import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.smartAccount.smartAccountBatchedUserOperations({
chain: "arbitrum",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
operations: [
{
body: {
actionType: "SET_ALLOWANCE",
token: "USDC",
contract: "UniswapV3Router",
amount: "1000",
},
},
],
});
console.log(result);
}
run();The standalone function version of this method:
import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { smartAccountSmartAccountBatchedUserOperations } from "@compass-labs/api-sdk/funcs/smartAccountSmartAccountBatchedUserOperations.js";
// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await smartAccountSmartAccountBatchedUserOperations(compassApiSDK, {
chain: "arbitrum",
sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
operations: [
{
body: {
actionType: "SET_ALLOWANCE",
token: "USDC",
contract: "UniswapV3Router",
amount: "1000",
},
},
],
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("smartAccountSmartAccountBatchedUserOperations failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.BatchedUserOperationsRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.BatchedUserOperationsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.APIError | 4XX, 5XX | */* |