Swagger

Networks

Which chains this deployment serves, and which token an operation can pay its fee in.

What the two reads tell you

Two reads answer everything a prepare needs to know about a chain: where this deployment can operate, and what a fee can be charged in there. Both are served by the gateway rather than read off a chain, so treat them as the authority and fetch them instead of hardcoding a list that will drift.

A networkId is the chain id, as a string

The networkId field uses the EVM chain id as a decimal string: "1", "137", "42161", "43114". Signing payloads can use numeric chainId fields; preserve the types returned by prepare.

The list is what UGTP serves, not what the chain supports

GET /network/list is the serviceable set behind this deployment. A chain missing from it is not a chain that is down — it is one this deployment does not carry, and no amount of retrying will prepare an operation there.

The fee-token list is short for a reason

GET /network/:networkId/tokens is what an operation can pay its fee in on that network. A token qualifies only if the fee-collecting contracts can value it in USD from a price feed, because the fee has a dollar-denominated part. That is a property of the token, not a preference, so a token's absence is not something a request can work around — name a listed fee token instead.

It is not the same list as the swap catalog

The tokens you can swap are a far longer list, and they come from the routing provider rather than from us: GET /swap/tokens. A token can be swappable and still be unable to pay a fee. Read the fee list for feeToken and the swap catalog for fromToken and toToken.

Read the execution mechanism from prepare

The network, asset and project determine the rail. Branch on the prepare response instead of maintaining a local network-to-rail table. On Avalanche, ERC-20 operations and native transfers use different rails.

Worked example

Choosing a network and a fee token

Two reads answer both questions a prepare needs: where you can operate, and what the fee can be charged in.

  1. 01

    List what this deployment serves

    GET /network/list

    The serviceable set comes from the gateway rather than from a chain, so treat this list as the authority on which networkId values a prepare will accept.

    Input — the request

    curl -X GET "https://api.ugtp.io/v1/network/list" \
      -H "X-API-Key: $UGTP_API_KEY"

    Output — 200 response

    {
      "networks": [
        {
          "name": "Avalanche C-Chain",
          "networkId": "43114",
          "explorerUrl": "https://snowtrace.io",
          "nativeCoin": "AVAX",
          "wrappedNative": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7"
        }
      ]
    }

    Every status this call can answer with
    StatusWhen
    200Networks
    401Missing or invalid credentials
    429Rate limit exceeded — retry after the number of seconds in the `Retry-After` response header
    500Internal server error
  2. 02

    Read a network's fee tokens

    GET /network/:networkId/tokens

    A fee token must be one of these. The executor rail always needs one named, so this read is a prerequisite there rather than an optimization.

    Input — the request

    curl -X GET "https://api.ugtp.io/v1/network/:networkId/tokens" \
      -H "X-API-Key: $UGTP_API_KEY"

    Output — 200 response

    {
      "networkId": "43114",
      "tokens": [
        {
          "address": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
          "symbol": "USDC",
          "decimals": 6
        }
      ]
    }

    Every status this call can answer with
    StatusWhen
    200Tokens
    401Missing or invalid credentials
    429Rate limit exceeded — retry after the number of seconds in the `Retry-After` response header
    500Internal server error
  3. 03

    Price the operation before signing

    POST /fee/estimate

    Reserve against estimatedFee and show expectedFee. On the executor rail also honour requiredBalanceRaw, which is what the account must hold — not always the same as the fee.

    Input — the request

    curl -X POST "https://api.ugtp.io/v1/fee/estimate" \
      -H "X-API-Key: $UGTP_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "networkId": "137",
      "senderAddress": "0xCa9d43184Cc3179609f77D38433D363833C73c60",
      "calls": [
        {
          "to": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
          "value": "0x0",
          "data": "0x..."
        }
      ],
      "transferredAssets": [
        {
          "address": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
          "amount": "0xf4240"
        }
      ],
      "feeToken": "0xc2132D05D31c914a87C6611C10748AEb04B58e8F"
    }'

    Output — 200 response

    {
      "estimatedFee": "0.0512",
      "estimatedFeeRaw": "0xc7f8",
      "expectedFee": "0.0410",
      "expectedFeeRaw": "0xa028",
      "gasFee": "0.0400",
      "gasFeeRaw": "0x9c40",
      "serviceFee": "0.0010",
      "serviceFeeRaw": "0x3e8",
      "symbol": "USDT"
    }

    Every status this call can answer with
    StatusWhen
    200Fee estimate
    400Invalid request body or query parameters
    401Missing or invalid credentials
    429Rate limit exceeded — retry after the number of seconds in the `Retry-After` response header
    500Internal server error