Intents/Swap

Swap Intent Estimate

Estimate the outcome of a swap intent prior to execution. It returns key details such as the expected output amount, applicable network fees, and potential slippage, enabling users to make informed transaction decisions.

Dev Tools Available!

For quick testing purposes, we provide development tools like the Okto Auth Token Generator. This tool helps you generate authentication tokens instantly, making it easier to test our APIs.

POST Request

Endpoint

POST https://sandbox-api.okto.tech/api/oc/v1/estimate

Headers

NameTypeDescription
Content-TypestringMust be application/json
AuthorizationstringBearer token for authentication

Request Body

{
  "method": "estimate",
  "jsonrpc": "2.0",
  "id": "<request-id>",
  "params": [
    {
      "type": "string", // Specify the type of Intent
      "jobId": "string", 
      "paymasterData": "string", 
      "gasDetails": {
          "maxFeePerGas": "string",
          "maxPriorityFeePerGas": "string"
      },
      "details": {
          "fromChainTokenAddress": "string",
          "fromChainCaip2Id": "string",
          "toChainTokenAddress": "string",
          "toChainCaip2Id": "string",
          "sameChainFee": "string",
          "sameChainFeeCollector": "string",
          "crossChainFee": "string",
          "crossChainFeeCollector": "string",
          "fromChainTokenAmount": "string",
          "minToTokenAmount": "string",
          "slippage": "string",
          "advancedSettings": {}
      }
  }
  ]
}
Tip:Request Parameters
Show
  • fromChainTokenAddress: Address of the token on the source chain.
  • fromChainCaip2Id: Chain ID for the source chain.
  • toChainTokenAddress: Address of the token on the destination chain.
  • toChainCaip2Id: Chain ID for the destination chain.
  • sameChainFee: Estimated gas fee for same-chain transfers.
  • sameChainFeeCollector: Address to collect the fee for same-chain transfers.
  • crossChainFee: Estimated gas fee for cross-chain transfers.
  • crossChainFeeCollector: Address to collect the fee for cross-chain transfers.
  • fromChainTokenAmount: Amount of tokens to transfer from the source chain.
  • minToTokenAmount: Minimum amount of tokens expected on the destination chain.
  • slippage: Maximum allowable slippage percentage for the transfer.

Response

{
  "jsonrpc": "2.0",
  "id": "<request-id>",
  "result": {
    "data": {
        "status": "success",
       "data": {
        "callData": {
            "clientSWA": "string",
            "feePayerAddress": "string",
            "gsn": {
                "isPossible": boolean,
                "isRequired": boolean,
                "requiredNetworks": [],
                "tokens": []
            },
            "intentType": "string",
            "jobId": "string",
            "payload": {
                "advancedSettings": {
                    "slippageUsed": "string"
                },
                "crossChainFee": "string",
                "crossChainFeeCollector": "string",
                "fromChainCaip2Id": "string",
                "fromChainTokenAddress": "string",
                "fromChainTokenAmount": "string",
                "minToTokenAmount": "string",
                "routeId": "string",
                "sameChainFee": "string",
                "sameChainFeeCollector": "string",
                "slippage": "string",
                "toChainCaip2Id": "string",
                "toChainTokenAddress": "string"
            },
            "policies": {
                "gsnEnabled": boolean,
                "sponsorshipEnabled": boolean
            },
            "userSWA": "string"
        },
        "details": {
            "estimation": {
                "amount": "string",
                "crossChainFee": "string",
                "crossChainFeeCollector": "string",
                "gasFeesInInputToken": "string",
                "integratorFeesInInputToken": "string",
                "outputAmount": "string",
                "platformBaseFeesInInputToken": "string",
                "recommendedSlippage": "string",
                "routeId": "string",
                "routeValidUntil": "string",
                "sameChainFee": "string",
                "sameChainFeeCollector": "string",
                "slippageUsed": "string",
                "totalFeesInInputToken": "string"
            },
            "fees": {
                "approxTransactionFeesInUSDT": "string",
                "transactionFees": {
                    "eip155:137": "string"
                }
            },
            "swapFees": {
                "gasFeesInInputToken": "string",
                "integratorFeesInInputToken": "string",
                "platformBaseFeesInInputToken": "string",
                "totalFeesInInputToken": "string"
            }
        },
        "userOps": {  
            "callData": "string",
            "callGasLimit": "string",
            "maxFeePerGas": "string",
            "maxPriorityFeePerGas": "string",
            "nonce": "string",
            "paymaster": "string",
            "paymasterData": "string",
            "paymasterPostOpGasLimit": "string",
            "paymasterVerificationGasLimit": "string",
            "preVerificationGas": "string",
            "sender": "string",
            "verificationGasLimit": "string"
        }
      }
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": "<request-id>",
  "error": {
    "code": "number",      // Error code
    "message": "string",   // Error message
    "data": "string"       // Additional error details
  }
}

Example

curl -X POST https://sandbox-api.okto.tech/api/oc/v1/estimate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <authToken>" \
  -d '{
    "type": "SWAP",
    "jobId": "51ec9e6d-7619-4eb6-b5d3-9cd725c07e5c",
    "feePayerAddress": "0xc639d4a31f3fE183D1816a9aC39518494208234F",
    "paymasterData": "0x00000000000000000000000098d0464243b04121d49d87d8035e5d29f87c208c000000000000000000000000000000000000000000000000000000006d0db17b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000416910710b0cc953aada640d4c8e4b62c7a42e2eebfcfc6bd071601b28c9f418bd01073f4b6ef015df9608e507e629f4cd65c7dc261973c4a609e90afe58f612cf1c00000000000000000000000000000000000000000000000000000000000000",
    "gasDetails": {
      "maxFeePerGas": "",
      "maxPriorityFeePerGas": ""
    },
    "details": {
      "fromChainCaip2Id": "eip155:42161",
      "fromChainTokenAmount": "800005",
      "toChainCaip2Id": "eip155:8453",
      "fromChainTokenAddress": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
      "toChainTokenAddress": "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
      "slippage": "3",
      "sameChainFee": "0",
      "sameChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
      "crossChainFee": "10",
      "crossChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9"
    }
  }'
const fetch = require("node-fetch"); // if using Node.js
 
const url = "https://sandbox-api.okto.tech/api/oc/v1/estimate";
const headers = {
  "Content-Type": "application/json",
  "Authorization": "Bearer <authToken>"
};
 
const body = {
  type: "SWAP",
  jobId: "51ec9e6d-7619-4eb6-b5d3-9cd725c07e5c",
  feePayerAddress: "0xc639d4a31f3fE183D1816a9aC39518494208234F",
  paymasterData: "0x00000000000000000000000098d0464243b04121d49d87d8035e5d29f87c208c000000000000000000000000000000000000000000000000000000006d0db17b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000416910710b0cc953aada640d4c8e4b62c7a42e2eebfcfc6bd071601b28c9f418bd01073f4b6ef015df9608e507e629f4cd65c7dc261973c4a609e90afe58f612cf1c00000000000000000000000000000000000000000000000000000000000000",
  gasDetails: {
    maxFeePerGas: "",
    maxPriorityFeePerGas: ""
  },
  details: {
    fromChainCaip2Id: "eip155:42161",
    fromChainTokenAmount: "800005",
    toChainCaip2Id: "eip155:8453",
    fromChainTokenAddress: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
    toChainTokenAddress: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
    slippage: "3",
    sameChainFee: "0",
    sameChainFeeCollector: "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
    crossChainFee: "10",
    crossChainFeeCollector: "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9"
  }
};
 
fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(body)
})
  .then((res) => res.json())
  .then((data) => console.log(data))
  .catch((err) => console.error(err));
package main
 
import (
  "bytes"
  "fmt"
  "io"
  "net/http"
)
 
func main() {
  url := "https://sandbox-api.okto.tech/api/oc/v1/estimate"
  method := "POST"
 
  payload := []byte(`{
    "type": "SWAP",
    "jobId": "51ec9e6d-7619-4eb6-b5d3-9cd725c07e5c",
    "feePayerAddress": "0xc639d4a31f3fE183D1816a9aC39518494208234F",
    "paymasterData": "0x00000000000000000000000098d0464243b04121d49d87d8035e5d29f87c208c000000000000000000000000000000000000000000000000000000006d0db17b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000416910710b0cc953aada640d4c8e4b62c7a42e2eebfcfc6bd071601b28c9f418bd01073f4b6ef015df9608e507e629f4cd65c7dc261973c4a609e90afe58f612cf1c00000000000000000000000000000000000000000000000000000000000000",
    "gasDetails": {
      "maxFeePerGas": "",
      "maxPriorityFeePerGas": ""
    },
    "details": {
      "fromChainCaip2Id": "eip155:42161",
      "fromChainTokenAmount": "800005",
      "toChainCaip2Id": "eip155:8453",
      "fromChainTokenAddress": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
      "toChainTokenAddress": "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
      "slippage": "3",
      "sameChainFee": "0",
      "sameChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
      "crossChainFee": "10",
      "crossChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9"
    }
  }`)
 
  client := &http.Client{}
  req, err := http.NewRequest(method, url, bytes.NewBuffer(payload))
 
  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("Content-Type", "application/json")
  req.Header.Add("Authorization", "Bearer <authToken>")
 
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()
 
  body, err := io.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
import requests
import json
 
url = "https://sandbox-api.okto.tech/api/oc/v1/estimate"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <authToken>"
}
 
payload = {
    "type": "SWAP",
    "jobId": "51ec9e6d-7619-4eb6-b5d3-9cd725c07e5c",
    "feePayerAddress": "0xc639d4a31f3fE183D1816a9aC39518494208234F",
    "paymasterData": "0x00000000000000000000000098d0464243b04121d49d87d8035e5d29f87c208c000000000000000000000000000000000000000000000000000000006d0db17b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000416910710b0cc953aada640d4c8e4b62c7a42e2eebfcfc6bd071601b28c9f418bd01073f4b6ef015df9608e507e629f4cd65c7dc261973c4a609e90afe58f612cf1c00000000000000000000000000000000000000000000000000000000000000",
    "gasDetails": {
        "maxFeePerGas": "",
        "maxPriorityFeePerGas": ""
    },
    "details": {
        "fromChainCaip2Id": "eip155:42161",
        "fromChainTokenAmount": "800005",
        "toChainCaip2Id": "eip155:8453",
        "fromChainTokenAddress": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
        "toChainTokenAddress": "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
        "slippage": "3",
        "sameChainFee": "0",
        "sameChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
        "crossChainFee": "10",
        "crossChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9"
    }
}
 
response = requests.post(url, headers=headers, data=json.dumps(payload))
print(response.text)

Response Examples

{
  "jsonrpc": "2.0",
  "id": "<request-id>",
  "result": {
    "data": {
        "status": "success",
       "data": {
        "callData": {
            "clientSWA": "0xc5a378Bb628Fec4A07a83996E1c9421fcdfA3C8E",
            "feePayerAddress": "0xc2D31Cdc6EFd02F85Ab943c4587f8D60E6E15F9c",
            "gsn": {
                "isPossible": false,
                "isRequired": false,
                "requiredNetworks": [
                    
                ],
                "tokens": [
                    
                ]
            },
            "intentType": "SWAP",
            "jobId": "154e6d24-d935-4c81-b029-44d59a71a499",
            "payload": {
                "advancedSettings": {
                    "slippageUsed": "13.5"
                },
                "crossChainFee": "0",
                "crossChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
                "fromChainCaip2Id": "eip155:137",
                "fromChainTokenAddress": "",
                "fromChainTokenAmount": "448556142516737632",
                "minToTokenAmount": "98001445185268",
                "routeId": "9f474742-6680-58c1-b56b-bc539813bae2",
                "sameChainFee": "0",
                "sameChainFeeCollector": "0x2c2505D0E21f32F38bCEBeca1C331ab4069bBCb9",
                "slippage": "1.5",
                "toChainCaip2Id": "eip155:56",
                "toChainTokenAddress": ""
            },
            "policies": {
                "gsnEnabled": false,
                "sponsorshipEnabled": false
            },
            "userSWA": "0xee5596022F7e4942d9f2ddFFf57bdad4Ae7160C3"
        },
        "details": {
            "estimation": {
                "amount": "",
                "crossChainFee": "",
                "crossChainFeeCollector": "",
                "gasFeesInInputToken": "21200",
                "integratorFeesInInputToken": "0",
                "outputAmount": "98001445185268",
                "platformBaseFeesInInputToken": "51",
                "recommendedSlippage": "13.5",
                "routeId": "9f474742-6680-58c1-b56b-bc539813bae2",
                "routeValidUntil": "",
                "sameChainFee": "",
                "sameChainFeeCollector": "",
                "slippageUsed": "13.5",
                "totalFeesInInputToken": "21251"
            },
            "fees": {
                "approxTransactionFeesInUSDT": "",
                "transactionFees": {
                    "eip155:137": "33321101955596672"
                }
            },
            "swapFees": {
                "gasFeesInInputToken": "21200",
                "integratorFeesInInputToken": "0",
                "platformBaseFeesInInputToken": "51",
                "totalFeesInInputToken": "21251"
            }
        },
        "userOps": {  
            "callData": "0x8dd7712f00000000000...00000000000",
            "callGasLimit": "0x5f7cd",
            "maxFeePerGas": "0x112a880",
            "maxPriorityFeePerGas": "0x112a880",
            "nonce": "0x00000000000000000000000000000000154e6d24d9354c81b02944d59a71a499",
            "paymaster": "0xc2d31cdc6efd02f85ab943c4587f8d60e6e15f9c",
            "paymasterData": "0x00000000000000000...0000000000",
            "paymasterPostOpGasLimit": "0x1cf9",
            "paymasterVerificationGasLimit": "0x13d6d",
            "preVerificationGas": "0x16b95",
            "sender": "0xee5596022f7e4942d9f2ddfff57bdad4ae7160c3",
            "verificationGasLimit": "0x28c6b"
        }
      }
    }
  }
}
{
  "jsonrpc": "2.0",
  "id": "25456a8f-8b66-4405-ad18-906aad82eba3",
  "error": {
    "code": -32603,
    "message": "Internal server error",
    "data": "error with downstream service"
  }
}