Gateway

class services.starkex.gateway.gateway.GatewayServiceVersion2(gateway_config: dict, storage: starkware.storage.storage.Storage)

This is the StarkEx Services HTTP gateway version2 for all external trading interactions.

async add_transaction(request)

Send a new transaction to StarkEx. This function handles all types of StarkEx transactions. Note: The transaction json must contain the object type.

Available tx types:

Parameters
  • tx_id (int) – Transaction sequence number issued by the caller.

  • tx (str) – Transaction type and the specific transaction parameters (listed below)

Returns

Transaction status (json).

Return type

str

Example for a SettlementRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "party_a_order": {
                "amount_buy": "80",
                "amount_sell": "70",
                "expiration_timestamp": 2171951,
                "fee_info": {
                    "fee_limit": "7",
                    "source_vault_id": 1210484339,
                    "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"
                },
                "nonce": 1654615998,
                "order_type": 0,
                "public_key": "0x4da5e70d4713d60c8a70639eb1167b367a9c3787c65c1e582e2e662f728b4fa",
                "signature": {
                    "r": "0x0",
                    "s": "0x0"
                },
                "token_buy": "0x22222222222222222222222222222222222222222222222222222222222222",
                "token_sell": "0x11111111111111111111111111111111111111111111111111111111111111",
                "type": "OrderL2Request",
                "vault_id_buy": 173879092,
                "vault_id_sell": 1806341205
            },
            "party_b_order": {
                "amount_buy": "30",
                "amount_sell": "40",
                "eth_address": "0xa9eb20c9A09F5eD00BE849049a554A60CCe4fC27",
                "expiration_timestamp": 989173,
                "nonce": 577090037,
                "order_type": 0,
                "token_buy": "0x11111111111111111111111111111111111111111111111111111111111111",
                "token_sell": "0x22222222222222222222222222222222222222222222222222222222222222",
                "type": "OrderL1Request",
                "vault_id_buy": 1095513148,
                "vault_id_sell": 271041745
            },
            "settlement_info": {
                "party_a_fee_info": {
                    "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
                    "destination_vault_id": 1654615998,
                    "fee_taken": "1"
                },
                "party_a_sold": "30",
                "party_b_sold": "40"
            },
            "type": "SettlementRequest"
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "party_a_order": {

                "amount_buy": "80",

                "amount_sell": "70",

                "expiration_timestamp": 2171951,

                "fee_info": {

                    "fee_limit": "7",

                    "source_vault_id": 1210484339,

                    "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"

                },

                "nonce": 1654615998,

                "order_type": 0,

                "public_key": "0x4da5e70d4713d60c8a70639eb1167b367a9c3787c65c1e582e2e662f728b4fa",

                "signature": {

                    "r": "0x0",

                    "s": "0x0"

                },

                "token_buy": "0x22222222222222222222222222222222222222222222222222222222222222",

                "token_sell": "0x11111111111111111111111111111111111111111111111111111111111111",

                "type": "OrderL2Request",

                "vault_id_buy": 173879092,

                "vault_id_sell": 1806341205

            },

            "party_b_order": {

                "amount_buy": "30",

                "amount_sell": "40",

                "eth_address": "0xa9eb20c9A09F5eD00BE849049a554A60CCe4fC27",

                "expiration_timestamp": 989173,

                "nonce": 577090037,

                "order_type": 0,

                "token_buy": "0x11111111111111111111111111111111111111111111111111111111111111",

                "token_sell": "0x22222222222222222222222222222222222222222222222222222222222222",

                "type": "OrderL1Request",

                "vault_id_buy": 1095513148,

                "vault_id_sell": 271041745

            },

            "settlement_info": {

                "party_a_fee_info": {

                    "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

                    "destination_vault_id": 1654615998,

                    "fee_taken": "1"

                },

                "party_a_sold": "30",

                "party_b_sold": "40"

            },

            "type": "SettlementRequest"

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "party_a_order": {

                "amount_buy": "80",

                "amount_sell": "70",

                "expiration_timestamp": 2171951,

                "fee_info": {

                    "fee_limit": "7",

                    "source_vault_id": 1210484339,

                    "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"

                },

                "nonce": 1654615998,

                "order_type": 0,

                "public_key": "0x4da5e70d4713d60c8a70639eb1167b367a9c3787c65c1e582e2e662f728b4fa",

                "signature": {

                    "r": "0x0",

                    "s": "0x0"

                },

                "token_buy": "0x22222222222222222222222222222222222222222222222222222222222222",

                "token_sell": "0x11111111111111111111111111111111111111111111111111111111111111",

                "type": "OrderL2Request",

                "vault_id_buy": 173879092,

                "vault_id_sell": 1806341205

            },

            "party_b_order": {

                "amount_buy": "30",

                "amount_sell": "40",

                "eth_address": "0xa9eb20c9A09F5eD00BE849049a554A60CCe4fC27",

                "expiration_timestamp": 989173,

                "nonce": 577090037,

                "order_type": 0,

                "token_buy": "0x11111111111111111111111111111111111111111111111111111111111111",

                "token_sell": "0x22222222222222222222222222222222222222222222222222222222222222",

                "type": "OrderL1Request",

                "vault_id_buy": 1095513148,

                "vault_id_sell": 271041745

            },

            "settlement_info": {

                "party_a_fee_info": {

                    "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

                    "destination_vault_id": 1654615998,

                    "fee_taken": "1"

                },

                "party_a_sold": "30",

                "party_b_sold": "40"

            },

            "type": "SettlementRequest"

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "party_a_order": {

                "amount_buy": "80",

                "amount_sell": "70",

                "expiration_timestamp": 2171951,

                "fee_info": {

                    "fee_limit": "7",

                    "source_vault_id": 1210484339,

                    "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"

                },

                "nonce": 1654615998,

                "order_type": 0,

                "public_key": "0x4da5e70d4713d60c8a70639eb1167b367a9c3787c65c1e582e2e662f728b4fa",

                "signature": {

                    "r": "0x0",

                    "s": "0x0"

                },

                "token_buy": "0x22222222222222222222222222222222222222222222222222222222222222",

                "token_sell": "0x11111111111111111111111111111111111111111111111111111111111111",

                "type": "OrderL2Request",

                "vault_id_buy": 173879092,

                "vault_id_sell": 1806341205

            },

            "party_b_order": {

                "amount_buy": "30",

                "amount_sell": "40",

                "eth_address": "0xa9eb20c9A09F5eD00BE849049a554A60CCe4fC27",

                "expiration_timestamp": 989173,

                "nonce": 577090037,

                "order_type": 0,

                "token_buy": "0x11111111111111111111111111111111111111111111111111111111111111",

                "token_sell": "0x22222222222222222222222222222222222222222222222222222222222222",

                "type": "OrderL1Request",

                "vault_id_buy": 1095513148,

                "vault_id_sell": 271041745

            },

            "settlement_info": {

                "party_a_fee_info": {

                    "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

                    "destination_vault_id": 1654615998,

                    "fee_taken": "1"

                },

                "party_a_sold": "30",

                "party_b_sold": "40"

            },

            "type": "SettlementRequest"

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "party_a_order": {\r\n\n                "amount_buy": "80",\r\n\n                "amount_sell": "70",\r\n\n                "expiration_timestamp": 2171951,\r\n\n                "fee_info": {\r\n\n                    "fee_limit": "7",\r\n\n                    "source_vault_id": 1210484339,\r\n\n                    "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"\r\n\n                },\r\n\n                "nonce": 1654615998,\r\n\n                "order_type": 0,\r\n\n                "public_key": "0x4da5e70d4713d60c8a70639eb1167b367a9c3787c65c1e582e2e662f728b4fa",\r\n\n                "signature": {\r\n\n                    "r": "0x0",\r\n\n                    "s": "0x0"\r\n\n                },\r\n\n                "token_buy": "0x22222222222222222222222222222222222222222222222222222222222222",\r\n\n                "token_sell": "0x11111111111111111111111111111111111111111111111111111111111111",\r\n\n                "type": "OrderL2Request",\r\n\n                "vault_id_buy": 173879092,\r\n\n                "vault_id_sell": 1806341205\r\n\n            },\r\n\n            "party_b_order": {\r\n\n                "amount_buy": "30",\r\n\n                "amount_sell": "40",\r\n\n                "eth_address": "0xa9eb20c9A09F5eD00BE849049a554A60CCe4fC27",\r\n\n                "expiration_timestamp": 989173,\r\n\n                "nonce": 577090037,\r\n\n                "order_type": 0,\r\n\n                "token_buy": "0x11111111111111111111111111111111111111111111111111111111111111",\r\n\n                "token_sell": "0x22222222222222222222222222222222222222222222222222222222222222",\r\n\n                "type": "OrderL1Request",\r\n\n                "vault_id_buy": 1095513148,\r\n\n                "vault_id_sell": 271041745\r\n\n            },\r\n\n            "settlement_info": {\r\n\n                "party_a_fee_info": {\r\n\n                    "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n                    "destination_vault_id": 1654615998,\r\n\n                    "fee_taken": "1"\r\n\n                },\r\n\n                "party_a_sold": "30",\r\n\n                "party_b_sold": "40"\r\n\n            },\r\n\n            "type": "SettlementRequest"\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a TransferRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "amount": "7106521602475165645",
            "expiration_timestamp": 2728011,
            "fee_info_exchange": {
                "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
                "destination_vault_id": 1654615998,
                "fee_taken": "5"
            },
            "fee_info_user": {
                "fee_limit": "15",
                "source_vault_id": 1210484339,
                "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"
            },
            "nonce": 1806341205,
            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",
            "receiver_vault_id": 1047589226,
            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",
            "sender_vault_id": 1358054485,
            "signature": {
                "r": "0x0",
                "s": "0x0"
            },
            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",
            "type": "TransferRequest"
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "amount": "7106521602475165645",

            "expiration_timestamp": 2728011,

            "fee_info_exchange": {

                "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

                "destination_vault_id": 1654615998,

                "fee_taken": "5"

            },

            "fee_info_user": {

                "fee_limit": "15",

                "source_vault_id": 1210484339,

                "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"

            },

            "nonce": 1806341205,

            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",

            "receiver_vault_id": 1047589226,

            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",

            "sender_vault_id": 1358054485,

            "signature": {

                "r": "0x0",

                "s": "0x0"

            },

            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",

            "type": "TransferRequest"

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "amount": "7106521602475165645",

            "expiration_timestamp": 2728011,

            "fee_info_exchange": {

                "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

                "destination_vault_id": 1654615998,

                "fee_taken": "5"

            },

            "fee_info_user": {

                "fee_limit": "15",

                "source_vault_id": 1210484339,

                "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"

            },

            "nonce": 1806341205,

            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",

            "receiver_vault_id": 1047589226,

            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",

            "sender_vault_id": 1358054485,

            "signature": {

                "r": "0x0",

                "s": "0x0"

            },

            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",

            "type": "TransferRequest"

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "amount": "7106521602475165645",

            "expiration_timestamp": 2728011,

            "fee_info_exchange": {

                "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

                "destination_vault_id": 1654615998,

                "fee_taken": "5"

            },

            "fee_info_user": {

                "fee_limit": "15",

                "source_vault_id": 1210484339,

                "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"

            },

            "nonce": 1806341205,

            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",

            "receiver_vault_id": 1047589226,

            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",

            "sender_vault_id": 1358054485,

            "signature": {

                "r": "0x0",

                "s": "0x0"

            },

            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",

            "type": "TransferRequest"

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "amount": "7106521602475165645",\r\n\n            "expiration_timestamp": 2728011,\r\n\n            "fee_info_exchange": {\r\n\n                "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n                "destination_vault_id": 1654615998,\r\n\n                "fee_taken": "5"\r\n\n            },\r\n\n            "fee_info_user": {\r\n\n                "fee_limit": "15",\r\n\n                "source_vault_id": 1210484339,\r\n\n                "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"\r\n\n            },\r\n\n            "nonce": 1806341205,\r\n\n            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",\r\n\n            "receiver_vault_id": 1047589226,\r\n\n            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",\r\n\n            "sender_vault_id": 1358054485,\r\n\n            "signature": {\r\n\n                "r": "0x0",\r\n\n                "s": "0x0"\r\n\n            },\r\n\n            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",\r\n\n            "type": "TransferRequest"\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a ConditionalTransferRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "amount": "7106521602475165645",
            "expiration_timestamp": 2728011,
            "fact": "cd7110159df66d2b4164484d6440f7099f8492f5c20d4cde01009b0d4ab85bbf",
            "fact_registry_address": "0xCc6E2d20cC5AaFDCa329bA2d63e5ba5edD684B2F",
            "nonce": 1806341205,
            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",
            "receiver_vault_id": 1047589226,
            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",
            "sender_vault_id": 1358054485,
            "signature": {
                "r": "0x0",
                "s": "0x0"
            },
            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",
            "type": "ConditionalTransferRequest"
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "amount": "7106521602475165645",

            "expiration_timestamp": 2728011,

            "fact": "cd7110159df66d2b4164484d6440f7099f8492f5c20d4cde01009b0d4ab85bbf",

            "fact_registry_address": "0xCc6E2d20cC5AaFDCa329bA2d63e5ba5edD684B2F",

            "nonce": 1806341205,

            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",

            "receiver_vault_id": 1047589226,

            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",

            "sender_vault_id": 1358054485,

            "signature": {

                "r": "0x0",

                "s": "0x0"

            },

            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",

            "type": "ConditionalTransferRequest"

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "amount": "7106521602475165645",

            "expiration_timestamp": 2728011,

            "fact": "cd7110159df66d2b4164484d6440f7099f8492f5c20d4cde01009b0d4ab85bbf",

            "fact_registry_address": "0xCc6E2d20cC5AaFDCa329bA2d63e5ba5edD684B2F",

            "nonce": 1806341205,

            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",

            "receiver_vault_id": 1047589226,

            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",

            "sender_vault_id": 1358054485,

            "signature": {

                "r": "0x0",

                "s": "0x0"

            },

            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",

            "type": "ConditionalTransferRequest"

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "amount": "7106521602475165645",

            "expiration_timestamp": 2728011,

            "fact": "cd7110159df66d2b4164484d6440f7099f8492f5c20d4cde01009b0d4ab85bbf",

            "fact_registry_address": "0xCc6E2d20cC5AaFDCa329bA2d63e5ba5edD684B2F",

            "nonce": 1806341205,

            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",

            "receiver_vault_id": 1047589226,

            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",

            "sender_vault_id": 1358054485,

            "signature": {

                "r": "0x0",

                "s": "0x0"

            },

            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",

            "type": "ConditionalTransferRequest"

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "amount": "7106521602475165645",\r\n\n            "expiration_timestamp": 2728011,\r\n\n            "fact": "cd7110159df66d2b4164484d6440f7099f8492f5c20d4cde01009b0d4ab85bbf",\r\n\n            "fact_registry_address": "0xCc6E2d20cC5AaFDCa329bA2d63e5ba5edD684B2F",\r\n\n            "nonce": 1806341205,\r\n\n            "receiver_public_key": "0x5548582de1b372ad3fbf47a7e5b1e7f9ca5499d004ae545a0116be5ab0c1681",\r\n\n            "receiver_vault_id": 1047589226,\r\n\n            "sender_public_key": "0x6f25e2a5a92118719c78df48f4ff31e78de58575487ce1eaf19922ad9b8a714",\r\n\n            "sender_vault_id": 1358054485,\r\n\n            "signature": {\r\n\n                "r": "0x0",\r\n\n                "s": "0x0"\r\n\n            },\r\n\n            "token": "0x71545a17a1d50068d723104f77383c13458a748e9bb17bca3f2c9bf9c6316b9",\r\n\n            "type": "ConditionalTransferRequest"\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a DepositRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "amount": "4029557120079369747",
            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
            "token_id": "0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",
            "type": "DepositRequest",
            "vault_id": 1654615998
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "DepositRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "DepositRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "DepositRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "amount": "4029557120079369747",\r\n\n            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n            "token_id": "0x2dd48fd7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",\r\n\n            "type": "DepositRequest",\r\n\n            "vault_id": 1654615998\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a MintRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "amount": "4029557120079369747",
            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
            "token_id": "0x400b7527a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",
            "type": "MintRequest",
            "vault_id": 1654615998
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x400b7527a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "MintRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x400b7527a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "MintRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x400b7527a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "MintRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "amount": "4029557120079369747",\r\n\n            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n            "token_id": "0x400b7527a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",\r\n\n            "type": "MintRequest",\r\n\n            "vault_id": 1654615998\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a WithdrawalRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "amount": "4029557120079369747",
            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
            "token_id": "0x5ba91fa7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",
            "type": "WithdrawalRequest",
            "vault_id": 1654615998
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x5ba91fa7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "WithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x5ba91fa7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "WithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "amount": "4029557120079369747",

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "token_id": "0x5ba91fa7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",

            "type": "WithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "amount": "4029557120079369747",\r\n\n            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n            "token_id": "0x5ba91fa7a024204f7c1bd874da5e709d4713d60c8a70639eb1167b367a9c378",\r\n\n            "type": "WithdrawalRequest",\r\n\n            "vault_id": 1654615998\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a FullWithdrawalRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
            "type": "FullWithdrawalRequest",
            "vault_id": 1654615998
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "type": "FullWithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "type": "FullWithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "type": "FullWithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n            "type": "FullWithdrawalRequest",\r\n\n            "vault_id": 1654615998\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
Example for a FalseFullWithdrawalRequest

http

POST /v2/gateway/add_transaction HTTP/1.1
Host: localhost:9411
Accept: application/json

            {
        "tx": {
            "requester_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
            "type": "FalseFullWithdrawalRequest",
            "vault_id": 1654615998
        },
        "tx_id": 1234
    }

curl

curl -i -X POST https://localhost:9411/v2/gateway/add_transaction -H "Accept: application/json" --data-raw '{

        "tx": {

            "requester_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "type": "FalseFullWithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

wget

wget -S -O- https://localhost:9411/v2/gateway/add_transaction --header="Accept: application/json" --post-data='{

        "tx": {

            "requester_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "type": "FalseFullWithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }'

httpie

echo '{

        "tx": {

            "requester_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",

            "type": "FalseFullWithdrawalRequest",

            "vault_id": 1654615998

        },

        "tx_id": 1234

    }' | http POST https://localhost:9411/v2/gateway/add_transaction Accept:application/json

python-requests

requests.post('https://localhost:9411/v2/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n        "tx": {\r\n\n            "requester_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",\r\n\n            "type": "FalseFullWithdrawalRequest",\r\n\n            "vault_id": 1654615998\r\n\n        },\r\n\n        "tx_id": 1234\r\n\n    }')

response

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

{"code": "TRANSACTION_PENDING"}
async get_first_unused_tx_id(request)

Gets the next transaction id that all of its predecessors exist in the system. If no ids exist in the system - then 0 will be returned.

While most of the time this implies the next tx_id used should be the returned value, this is not guaranteed, since while this value is returned, some new transaction may be written, rendering the returned response irrelevant.

Returns

The next consecutive tx_id, all of its predecessors exist in our system.

Return type

int

Example

http

GET /v2/gateway/testing/get_first_unused_tx_id HTTP/1.1
Host: localhost:9411
Accept: application/json

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 8

5678

curl

curl -i https://localhost:9411/v2/gateway/testing/get_first_unused_tx_id -H "Accept: application/json" --data-raw 'HTTP/1.1 200 OK

Content-Type: text/plain; charset=utf-8

Content-Length: 8



5678'

wget

wget -S -O- https://localhost:9411/v2/gateway/testing/get_first_unused_tx_id --header="Accept: application/json" --body-data='HTTP/1.1 200 OK

Content-Type: text/plain; charset=utf-8

Content-Length: 8



5678'

httpie

echo 'HTTP/1.1 200 OK

Content-Type: text/plain; charset=utf-8

Content-Length: 8



5678' | http https://localhost:9411/v2/gateway/testing/get_first_unused_tx_id Accept:application/json

python-requests

requests.get('https://localhost:9411/v2/gateway/testing/get_first_unused_tx_id', headers={'Accept': 'application/json'}, data='HTTP/1.1 200 OK\r\n\nContent-Type: text/plain; charset=utf-8\r\n\nContent-Length: 8\r\n\n\r\n\n5678')
async get_stark_dex_address(request)

Get the StarkEx contract address. This is the address used for registering keys and tokens, and performing onchain deposits and withdrawals.

Returns

On-chain StarkEx contract address.

Return type

str

Example

http

GET /v2/gateway/testing/get_stark_dex_address HTTP/1.1
Host: localhost:9411
Accept: application/json

curl

curl -i https://localhost:9411/v2/gateway/testing/get_stark_dex_address -H "Accept: application/json"

wget

wget -S -O- https://localhost:9411/v2/gateway/testing/get_stark_dex_address --header="Accept: application/json"

httpie

http https://localhost:9411/v2/gateway/testing/get_stark_dex_address Accept:application/json

python-requests

requests.get('https://localhost:9411/v2/gateway/testing/get_stark_dex_address', headers={'Accept': 'application/json'})

response

HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 44

"0x8013A6840804aA0DC68f544cBa0a9baF1bE2315A"
async get_transaction(request)

Get specific transaction’s information.

Parameters

tx_id (int) – Transaction ID to query.

Returns

Information of the queried transaction (json).

Return type

str

Example

http

GET /v2/gateway/get_transaction?tx_id=1234 HTTP/1.1
Host: localhost:9411
Accept: application/json

curl

curl -i 'https://localhost:9411/v2/gateway/get_transaction?tx_id=1234' -H "Accept: application/json"

wget

wget -S -O- 'https://localhost:9411/v2/gateway/get_transaction?tx_id=1234' --header="Accept: application/json"

httpie

http 'https://localhost:9411/v2/gateway/get_transaction?tx_id=1234' Accept:application/json

python-requests

requests.get('https://localhost:9411/v2/gateway/get_transaction?tx_id=1234', headers={'Accept': 'application/json'})

response

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

    {
        "party_a_order": {
            "amount_buy": "80",
            "amount_sell": "70",
            "expiration_timestamp": 2171951,
            "fee_info": {
                "fee_limit": "7",
                "source_vault_id": 1210484339,
                "token_id": "0x23a77118133287637ebdcd9e87a1613e443df789558867f5ba91faf7a024204"
            },
            "nonce": 1654615998,
            "order_type": 0,
            "public_key": "0x4da5e70d4713d60c8a70639eb1167b367a9c3787c65c1e582e2e662f728b4fa",
            "signature": {
                "r": "0x0",
                "s": "0x0"
            },
            "token_buy": "0x22222222222222222222222222222222222222222222222222222222222222",
            "token_sell": "0x11111111111111111111111111111111111111111111111111111111111111",
            "type": "OrderL2Request",
            "vault_id_buy": 173879092,
            "vault_id_sell": 1806341205
        },
        "party_b_order": {
            "amount_buy": "30",
            "amount_sell": "40",
            "eth_address": "0xa9eb20c9A09F5eD00BE849049a554A60CCe4fC27",
            "expiration_timestamp": 989173,
            "nonce": 577090037,
            "order_type": 0,
            "token_buy": "0x11111111111111111111111111111111111111111111111111111111111111",
            "token_sell": "0x22222222222222222222222222222222222222222222222222222222222222",
            "type": "OrderL1Request",
            "vault_id_buy": 1095513148,
            "vault_id_sell": 271041745
        },
        "settlement_info": {
            "party_a_fee_info": {
                "destination_stark_key": "0x7c65c1e82e2e662f728b4fa42485e3a0a5d2f346baa9455e3e70682c2094cac",
                "destination_vault_id": 1654615998,
                "fee_taken": "1"
            },
            "party_a_sold": "30",
            "party_b_sold": "40"
        },
        "type": "SettlementRequest"
    }