Feeder Gateway

class services.starkex.feeder_gateway.feeder_gateway.FeederGateway

This is the StarkEx Services HTTP gateway for feeder interactions. The Feeder is a gateway to the StarkEx system for retrieving transaction batch information by external parties. Access to information is based on batch IDs only. The intention is to allow more detailed slicing and dicing to be performed on an external DB rather than via this API.

async get_batch_enclosing_ids(request: aiohttp.web_request.Request) aiohttp.web_response.Response

Get first and last transaction IDs for the input batch_id.

Parameters

batch_id (int) – Batch ID to query.

Returns

List of first and last batch IDs (json).

Return type

str

Example

http

GET /feeder_gateway/v2/get_batch_enclosing_ids?batch_id=5678 HTTP/1.1
Host: localhost:9413
Accept: application/json

curl

curl -i -X GET 'https://localhost:9413/feeder_gateway/v2/get_batch_enclosing_ids?batch_id=5678' -H "Accept: application/json"

wget

wget -S -O- 'https://localhost:9413/feeder_gateway/v2/get_batch_enclosing_ids?batch_id=5678' --header="Accept: application/json"

httpie

http 'https://localhost:9413/feeder_gateway/v2/get_batch_enclosing_ids?batch_id=5678' Accept:application/json

python-requests

requests.get('https://localhost:9413/feeder_gateway/v2/get_batch_enclosing_ids?batch_id=5678', headers={'Accept': 'application/json'})

response

HTTP/1.1 200 OK
Content-Type: application/json

[10000, 12345]
async get_batch_ids(request: aiohttp.web_request.Request) aiohttp.web_response.Response

This function is deprecated and will be deleted in the next version.

Get a list of batch IDs matching the input vaults root, orders root and sequence number.

Parameters
  • vault_root (int) – Vaults root to query.

  • order_root (int) – Orders root to query.

  • sequence_number (int) – Sequence number to query.

Returns

List of batch IDs (json).

Return type

str

Example

http

GET /feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678 HTTP/1.1
Host: localhost:9413
Accept: application/json

curl

curl -i -X GET 'https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678' -H "Accept: application/json"

wget

wget -S -O- 'https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678' --header="Accept: application/json"

httpie

http 'https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678' Accept:application/json

python-requests

requests.get('https://localhost:9413/feeder_gateway/get_batch_ids?vault_root=0x46bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1&order_root=0x84695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8&sequence_number=5678', headers={'Accept': 'application/json'})

response

HTTP/1.1 200 OK
Content-Type: application/json

[123, 456]
async get_batch_info(request: aiohttp.web_request.Request) aiohttp.web_response.Response

This function is deprecated and will be deleted in the next version.

Get detailed batch information. Please note that the returned order roots (prev_order_root and order_root) can be either roots of a Merkle tree or roots of a Patricia tree. If the batch was created prior the upgrade to V4.5 the roots will be of a Merkle tree, otherwise the roots will be of a Patrica tree. See the response example for returned keys and values.

Parameters

batch_id (int) – Batch ID to query.

Returns

Batch information (json).

Return type

str

Example

http

GET /feeder_gateway/get_batch_info?batch_id=5678 HTTP/1.1
Host: localhost:9413
Accept: application/json

curl

curl -i -X GET 'https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678' -H "Accept: application/json"

wget

wget -S -O- 'https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678' --header="Accept: application/json"

httpie

http 'https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678' Accept:application/json

python-requests

requests.get('https://localhost:9413/feeder_gateway/get_batch_info?batch_id=5678', headers={'Accept': 'application/json'})

response

HTTP/1.1 200 OK
Content-Type: application/json

    {
        "order_root": {
            "height": 31,
            "root": "04695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8"
        },
        "prev_batch_id": 5677,
        "prev_order_root": {
            "height": 31,
            "root": "04695d9d13ec0eeafc07b7d0c5da3f30e42e468bc69413c2b77e62cd8cdeb9a8"
        },
        "prev_vault_root": {
            "height": 31,
            "root": "0075364111a7a336756626d19fc8ec8df6328a5e63681c68ffaa312f6bf98c5c"
        },
        "sequence_number": 1234,
        "time_created": 1614665098,
        "txs_info": [
            {
                "alt_txs": [],
                "original_tx": {
                    "amount": "1000",
                    "stark_key": "0x51ddea3f6955ab96cdbb24e2b88c7ce6e7d1afea354e41be88d9dca5c7f0651",
                    "token_id": "0x2dc6cb834b9f656f3366c0c263e75458a814074b165bc1661b7460e7c972759",
                    "type": "DepositRequest",
                    "vault_id": 931081472
                },
                "tx_id": 123456,
                "was_replaced": false
            }
        ],
        "vault_root": {
            "height": 31,
            "root": "00bc9d7b7716bc33b1db5b7509c0a076ab9424ba5e16dd26de8097a62f1ef1d1"
        }
    }
async get_batch_info_version2(request: aiohttp.web_request.Request) aiohttp.web_response.Response

Get detailed batch information. See the response example for returned keys and values.

Parameters

batch_id (int) – Batch ID to query.

Returns

Batch information (json).

Return type

str

Example

http

GET /feeder_gateway/v2/get_batch_info?batch_id=5678 HTTP/1.1
Host: localhost:9413
Accept: application/json

curl

curl -i -X GET 'https://localhost:9413/feeder_gateway/v2/get_batch_info?batch_id=5678' -H "Accept: application/json"

wget

wget -S -O- 'https://localhost:9413/feeder_gateway/v2/get_batch_info?batch_id=5678' --header="Accept: application/json"

httpie

http 'https://localhost:9413/feeder_gateway/v2/get_batch_info?batch_id=5678' Accept:application/json

python-requests

requests.get('https://localhost:9413/feeder_gateway/v2/get_batch_info?batch_id=5678', headers={'Accept': 'application/json'})

response

HTTP/1.1 200 OK
Content-Type: application/json

    {
        "prev_batch_id": 5677,
        "sequence_number": 1234,
        "time_created": 1614665098,
        "txs_info": [
            {
                "alt_txs": [],
                "original_tx": {
                    "amount": "1000",
                    "stark_key": "0x51ddea3f6955ab96cdbb24e2b88c7ce6e7d1afea354e41be88d9dca5c7f0651",
                    "token_id": "0x2dc6cb834b9f656f3366c0c263e75458a814074b165bc1661b7460e7c972759",
                    "type": "DepositRequest",
                    "vault_id": 931081472
                },
                "tx_id": 123456,
                "was_replaced": false
            }
        ]
    }
async get_l1_blockchain_id(request: aiohttp.web_request.Request) aiohttp.web_response.Response

Returns the blockchain ID used by the system.

async get_last_batch_id(request: aiohttp.web_request.Request) aiohttp.web_response.Response

Get the last batch id used by StarkEx.

Returns

Last batch id.

Return type

int

Example

http

GET /feeder_gateway/v2/get_last_batch_id HTTP/1.1
Host: localhost:9413
Accept: application/json

HTTP/1.1 200 OK
Content-Type: application/json

5678

curl

curl -i -X GET https://localhost:9413/feeder_gateway/v2/get_last_batch_id -H "Accept: application/json" --data-raw 'HTTP/1.1 200 OK

Content-Type: application/json



5678'

wget

wget -S -O- https://localhost:9413/feeder_gateway/v2/get_last_batch_id --header="Accept: application/json" --body-data='HTTP/1.1 200 OK

Content-Type: application/json



5678'

httpie

echo 'HTTP/1.1 200 OK

Content-Type: application/json



5678' | http https://localhost:9413/feeder_gateway/v2/get_last_batch_id Accept:application/json

python-requests

requests.get('https://localhost:9413/feeder_gateway/v2/get_last_batch_id', headers={'Accept': 'application/json'}, data='HTTP/1.1 200 OK\r\n\nContent-Type: application/json\r\n\n\r\n\n5678')
async get_prev_batch_id(request: aiohttp.web_request.Request) aiohttp.web_response.Response

Get the previous batch id for the input batch_id.

Parameters

batch_id (int) – Batch ID to query.

Returns

The previous batch id.

Return type

int

Example

http

GET /feeder_gateway/v2/get_prev_batch_id?batch_id=5678 HTTP/1.1
Host: localhost:9413
Accept: application/json

curl

curl -i -X GET 'https://localhost:9413/feeder_gateway/v2/get_prev_batch_id?batch_id=5678' -H "Accept: application/json"

wget

wget -S -O- 'https://localhost:9413/feeder_gateway/v2/get_prev_batch_id?batch_id=5678' --header="Accept: application/json"

httpie

http 'https://localhost:9413/feeder_gateway/v2/get_prev_batch_id?batch_id=5678' Accept:application/json

python-requests

requests.get('https://localhost:9413/feeder_gateway/v2/get_prev_batch_id?batch_id=5678', headers={'Accept': 'application/json'})

response

HTTP/1.1 200 OK
Content-Type: application/json

5676
async is_alive(request: aiohttp.web_request.Request) aiohttp.web_response.Response
async is_ready(request: aiohttp.web_request.Request) aiohttp.web_response.Response