Python (SDK)
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.smart_account.smart_account_batched_user_operations(chain=models.BatchedUserOperationsRequestChain.ARBITRUM, sender="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", operations=[
models.UserOperation(
body=models.SetAllowanceParams(
token="USDC",
contract=models.SetAllowanceParamsContractEnum.UNISWAP_V3_ROUTER,
amount="1000",
),
),
], estimate_gas=True)
# Handle response
print(res)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",
estimateGas: true,
operations: [
{
body: {
actionType: "SET_ALLOWANCE",
token: "USDC",
contract: "UniswapV3Router",
amount: "1000",
},
},
],
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v1/smart_account/batched_user_operations \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"chain": "arbitrum",
"sender_": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
"estimate_gas": true,
"operations": [
{
"body": {
"action_type": "SET_ALLOWANCE",
"amount": "1000",
"contract": "UniswapV3Router",
"token": "USDC"
}
}
]
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chain: 'arbitrum',
sender_: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B',
estimate_gas: true,
operations: [
{
body: JSON.stringify({
action_type: 'SET_ALLOWANCE',
amount: '1000',
contract: 'UniswapV3Router',
token: 'USDC'
})
}
]
})
};
fetch('https://api.compasslabs.ai/v1/smart_account/batched_user_operations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.compasslabs.ai/v1/smart_account/batched_user_operations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chain' => 'arbitrum',
'sender_' => '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B',
'estimate_gas' => true,
'operations' => [
[
'body' => [
'action_type' => 'SET_ALLOWANCE',
'amount' => '1000',
'contract' => 'UniswapV3Router',
'token' => 'USDC'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v1/smart_account/batched_user_operations"
payload := strings.NewReader("{\n \"chain\": \"arbitrum\",\n \"sender_\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"estimate_gas\": true,\n \"operations\": [\n {\n \"body\": {\n \"action_type\": \"SET_ALLOWANCE\",\n \"amount\": \"1000\",\n \"contract\": \"UniswapV3Router\",\n \"token\": \"USDC\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v1/smart_account/batched_user_operations")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"chain\": \"arbitrum\",\n \"sender_\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"estimate_gas\": true,\n \"operations\": [\n {\n \"body\": {\n \"action_type\": \"SET_ALLOWANCE\",\n \"amount\": \"1000\",\n \"contract\": \"UniswapV3Router\",\n \"token\": \"USDC\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v1/smart_account/batched_user_operations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chain\": \"arbitrum\",\n \"sender_\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"estimate_gas\": true,\n \"operations\": [\n {\n \"body\": {\n \"action_type\": \"SET_ALLOWANCE\",\n \"amount\": \"1000\",\n \"contract\": \"UniswapV3Router\",\n \"token\": \"USDC\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"operations": [
{
"to": "<string>",
"data": "<string>",
"value": "<string>"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Smart Account
Get Smart Account Batched User Operations
Generate a list of user operations for smart account batching.
POST
/
v1
/
smart_account
/
batched_user_operations
Python (SDK)
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.smart_account.smart_account_batched_user_operations(chain=models.BatchedUserOperationsRequestChain.ARBITRUM, sender="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B", operations=[
models.UserOperation(
body=models.SetAllowanceParams(
token="USDC",
contract=models.SetAllowanceParamsContractEnum.UNISWAP_V3_ROUTER,
amount="1000",
),
),
], estimate_gas=True)
# Handle response
print(res)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",
estimateGas: true,
operations: [
{
body: {
actionType: "SET_ALLOWANCE",
token: "USDC",
contract: "UniswapV3Router",
amount: "1000",
},
},
],
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v1/smart_account/batched_user_operations \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"chain": "arbitrum",
"sender_": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
"estimate_gas": true,
"operations": [
{
"body": {
"action_type": "SET_ALLOWANCE",
"amount": "1000",
"contract": "UniswapV3Router",
"token": "USDC"
}
}
]
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chain: 'arbitrum',
sender_: '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B',
estimate_gas: true,
operations: [
{
body: JSON.stringify({
action_type: 'SET_ALLOWANCE',
amount: '1000',
contract: 'UniswapV3Router',
token: 'USDC'
})
}
]
})
};
fetch('https://api.compasslabs.ai/v1/smart_account/batched_user_operations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.compasslabs.ai/v1/smart_account/batched_user_operations",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chain' => 'arbitrum',
'sender_' => '0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B',
'estimate_gas' => true,
'operations' => [
[
'body' => [
'action_type' => 'SET_ALLOWANCE',
'amount' => '1000',
'contract' => 'UniswapV3Router',
'token' => 'USDC'
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v1/smart_account/batched_user_operations"
payload := strings.NewReader("{\n \"chain\": \"arbitrum\",\n \"sender_\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"estimate_gas\": true,\n \"operations\": [\n {\n \"body\": {\n \"action_type\": \"SET_ALLOWANCE\",\n \"amount\": \"1000\",\n \"contract\": \"UniswapV3Router\",\n \"token\": \"USDC\"\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.compasslabs.ai/v1/smart_account/batched_user_operations")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"chain\": \"arbitrum\",\n \"sender_\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"estimate_gas\": true,\n \"operations\": [\n {\n \"body\": {\n \"action_type\": \"SET_ALLOWANCE\",\n \"amount\": \"1000\",\n \"contract\": \"UniswapV3Router\",\n \"token\": \"USDC\"\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v1/smart_account/batched_user_operations")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chain\": \"arbitrum\",\n \"sender_\": \"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B\",\n \"estimate_gas\": true,\n \"operations\": [\n {\n \"body\": {\n \"action_type\": \"SET_ALLOWANCE\",\n \"amount\": \"1000\",\n \"contract\": \"UniswapV3Router\",\n \"token\": \"USDC\"\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"operations": [
{
"to": "<string>",
"data": "<string>",
"value": "<string>"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
application/json
Request model for batching user operations.
Used for smart account batching and 5792 batching.
Available options:
arbitrum, base, ethereum Example:
"arbitrum"
The address of the transaction sender.
Example:
"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"
List of possible user operations
Show child attributes
Show child attributes
Example:
{
"body": {
"action_type": "SET_ALLOWANCE",
"amount": "1000",
"contract": "UniswapV3Router",
"token": "USDC"
}
}Determines whether to estimate gas costs for transactions, also verifying that the transaction can be successfully executed.
Example:
true
Response
Successful Response
List of user operations to be batched and executed by the smart account.
Show child attributes
Show child attributes
Was this page helpful?
⌘I