from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.universal.generic_allowance(chain=models.V1GenericAllowanceChain.ARBITRUM, token="USDC", contract=models.V1GenericAllowanceContractEnum.AAVE_V3_POOL, user="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B")
# 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.universal.genericAllowance({
chain: "arbitrum",
user: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
token: "USDC",
contract: "AaveV3Pool",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v1/generic/allowance \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v1/generic/allowance', 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/generic/allowance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v1/generic/allowance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v1/generic/allowance")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v1/generic/allowance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"amount": 1.5,
"decimals": 18,
"token_symbol": "WETH",
"token_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"contract_address": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Get Allowance
In decentralized finance (DeFi) protocols such as Uniswap or AAVE, users must set a token allowance to authorize the protocol to spend a specified amount of their tokens on their behalf.
This is a crucial step before engaging in any transactions or operations within these protocols, ensuring that the protocol has the necessary permissions to manage the user’s tokens securely and efficiently.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.universal.generic_allowance(chain=models.V1GenericAllowanceChain.ARBITRUM, token="USDC", contract=models.V1GenericAllowanceContractEnum.AAVE_V3_POOL, user="0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B")
# 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.universal.genericAllowance({
chain: "arbitrum",
user: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
token: "USDC",
contract: "AaveV3Pool",
});
console.log(result);
}
run();curl --request GET \
--url https://api.compasslabs.ai/v1/generic/allowance \
--header 'x-api-key: <api-key>'const options = {method: 'GET', headers: {'x-api-key': '<api-key>'}};
fetch('https://api.compasslabs.ai/v1/generic/allowance', 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/generic/allowance",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"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"
"net/http"
"io"
)
func main() {
url := "https://api.compasslabs.ai/v1/generic/allowance"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.compasslabs.ai/v1/generic/allowance")
.header("x-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v1/generic/allowance")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["x-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"amount": 1.5,
"decimals": 18,
"token_symbol": "WETH",
"token_address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"contract_address": "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Query Parameters
arbitrum, base, ethereum The user to get the ERC20 allowance of.
The symbol or address of the token for which the allowance is checked. A token identifier - either a supported symbol (e.g., USDC, WETH) or a valid Ethereum address (0x...)
"USDC"
"WETH"
"0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8"
The name or address of the contract to check allowance for.
AaveV3Pool, AerodromeBasicRouter, AerodromeSlipstreamRouter, AerodromeSlipstreamNonfungiblePositionManager, UniswapV3Router, UniswapV3NFTPositionManager, MorphoMarket, SkyDaiUsdsConverter, SkyUsdcUsdsConverter, SkyUsdsVault, PendleRouter, OdosRouter, EthenaVault Response
Successful Response
Response model for token allowance information.
Amount of tokens allowed to be spent by spender
^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$1.5
Number of decimals of the token
18
Symbol of the token.
"WETH"
Address of the token
"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
Address of the contract
"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"
Was this page helpful?