get_token_allowance
The get_token_allowance method returns token allowance for address.
Refer to the 1inch Classic Swap documentation for more information.
Arguments
| Structure | Type | Description |
|---|---|---|
| coin | string | Token ticker |
| spender | string | Smart contract address to query spendable coins amount granted prior approval |
Response
| Structure | Type | Description |
|---|---|---|
| result | float | Amount of coins approved for spending via the smart contract (in coins units). |
📌 Examples
Command
POST get_token_allowance
{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "get_token_allowance",
"params": {
"coin": "AAVE-PLG20",
"spender": "0x083C32B38e8050473f6999e22f670d1404235592"
}
} curl --url "http://127.0.0.1:7783" --data '{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "get_token_allowance",
"params": {
"coin": "AAVE-PLG20",
"spender": "0x083C32B38e8050473f6999e22f670d1404235592"
}
}' import requests
import json
url = "http://127.0.0.1:7783"
payload = {
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "get_token_allowance",
"params": {
"coin": "AAVE-PLG20",
"spender": "0x083C32B38e8050473f6999e22f670d1404235592"
}
}
response = requests.post(url, json=payload)
print(json.dumps(response.json(), indent=2)) const payload = {
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "get_token_allowance",
"params": {
"coin": "AAVE-PLG20",
"spender": "0x083C32B38e8050473f6999e22f670d1404235592"
}
};
const response = await fetch("http://127.0.0.1:7783", {
method: "POST",
body: JSON.stringify(payload),
});
console.log(await response.json()); <?php
$payload = <<<'JSON'
{
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "get_token_allowance",
"params": {
"coin": "AAVE-PLG20",
"spender": "0x083C32B38e8050473f6999e22f670d1404235592"
}
}
JSON;
$ch = curl_init("http://127.0.0.1:7783");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response = curl_exec($ch);
curl_close($ch);
echo $response; package main
import (
"bytes"
"fmt"
"io"
"net/http"
)
func main() {
payload := []byte(`{"mmrpc":"2.0","userpass":"RPC_UserP@SSW0RD","method":"get_token_allowance","params":{"coin":"AAVE-PLG20","spender":"0x083C32B38e8050473f6999e22f670d1404235592"}}`)
resp, err := http.Post("http://127.0.0.1:7783", "application/json", bytes.NewBuffer(payload))
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
} require 'net/http'
require 'json'
require 'uri'
uri = URI("http://127.0.0.1:7783")
payload = {
"mmrpc": "2.0",
"userpass": "RPC_UserP@SSW0RD",
"method": "get_token_allowance",
"params": {
"coin": "AAVE-PLG20",
"spender": "0x083C32B38e8050473f6999e22f670d1404235592"
}
}
response = Net::HTTP.post(uri, payload.to_json, 'Content-Type' => 'application/json')
puts JSON.pretty_generate(JSON.parse(response.body)) Show Response
Response: Success
{
"mmrpc": "2.0",
"result": "1.23",
"id": null
} Show Error Responses
Error: Token config not activated
{
"mmrpc": "2.0",
"error": "No such coin USDT-ERC20",
"error_path": "tokens",
"error_trace": "tokens:171]",
"error_type": "NoSuchCoin",
"error_data": {
"coin": "USDT-ERC20"
},
"id": null
}