Gateway
Perpetual services HTTP gateway for external interactions.
add_transaction
/add_transaction
is the endpoint for sending transactions to the StarkEx Perpetual gateway.
Parameters
-
tx_id
(int) – Transaction sequence number issued by the caller. -
tx
(Transaction) – Transaction body
Available tx types:
Example
-
Deposit
-
http
-
curl
-
wget
-
httpie
-
python-requests
-
response
POST /gateway/add_transaction HTTP/1.1
Accept: application/json
{
"tx": {
"amount": "2569146471088859254",
"position_id": "7758176404715800194",
"public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a",
"type": "DEPOSIT"
},
"tx_id": 1
}
curl -i -X POST https://nohost/gateway/add_transaction -H "Accept: application/json" --data-raw '{
"tx": {
"amount": "2569146471088859254",
"position_id": "7758176404715800194",
"public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a",
"type": "DEPOSIT"
},
"tx_id": 1
}'
wget -S -O- https://nohost/gateway/add_transaction --header="Accept: application/json" --post-data='{
"tx": {
"amount": "2569146471088859254",
"position_id": "7758176404715800194",
"public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a",
"type": "DEPOSIT"
},
"tx_id": 1
}'
echo '{
"tx": {
"amount": "2569146471088859254",
"position_id": "7758176404715800194",
"public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a",
"type": "DEPOSIT"
},
"tx_id": 1
}' | http POST https://nohost/gateway/add_transaction Accept:application/json
requests.post('https://nohost/gateway/add_transaction', headers={'Accept': 'application/json'}, data='{\r\n\n "tx": {\r\n\n "amount": "2569146471088859254",\r\n\n "position_id": "7758176404715800194",\r\n\n "public_key": "0x37ebdcde87a1613e443df789558867f5ba91faf7a024204f7c1bd874da5e70a",\r\n\n "type": "DEPOSIT"\r\n\n },\r\n\n "tx_id": 1\r\n\n }')
HTTP/1.1 200 OK
Content-Type: application/json
{"code": "TRANSACTION_RECEIVED", "tx_id": 5678}
Parameters
-
code
– The response code of the request. -
tx_id
– The tx_id of the request this reponse belongs to.
get_first_unused_tx_id
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
-
curl
-
wget
-
httpie
-
python-requests
GET /gateway/get_first_unused_tx_id HTTP/1.1
Host: localhost:9611
Accept: application/json
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 8
5678
curl -i -X GET https://localhost:9611/gateway/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 -S -O- https://localhost:9611/gateway/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'
echo 'HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 8
5678' | http https://localhost:9611/gateway/get_first_unused_tx_id Accept:application/json
requests.get('https://localhost:9611/gateway/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')
get_starkex_contract_address
Gets the StarkEx contract address. This is the address used for registering keys and tokens, and performing onchain deposits and withdrawals.
Returns
-
Onchain StarkEx contract address.
Return type
-
str
Example
-
http
-
curl
-
wget
-
httpie
-
python-requests
-
response
GET /gateway/get_starkex_contract_address HTTP/1.1
Host: localhost:9411
Accept: application/json
curl -i -X GET https://localhost:9411/gateway/get_starkex_contract_address -H "Accept: application/json"
wget -S -O- https://localhost:9411/gateway/get_starkex_contract_address --header="Accept: application/json"
http https://localhost:9411/gateway/get_starkex_contract_address Accept:application/json
requests.get('https://localhost:9411/gateway/get_starkex_contract_address', headers={'Accept': 'application/json'})
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 44
"0x8013A6840804aA0DC68f544cBa0a9baF1bE2315A"
set_alternative_endpoint_config
Updates the alternative-transaction endpoint configuration. In order to use this request, StarkWare must configure your setup to support dynamically configuring the endpoint for alternative transactions.
NOTE: The updated configuration will be used by the alternative-transaction mechanism only if dynamic configuration is enabled.
The dynamic configuration request class: AlternativeEndpointSettingRequest
Returns
-
A message stating if the configuration request is accepted or rejected.
Return type
-
str
Example
-
http
-
curl
-
wget
-
httpie
-
python-requests
-
response
POST /gateway/set_alternative_endpoint_config HTTP/1.1
Host: localhost:9411
Accept: application/json
{
"bearer_token": "123-456-789",
"client_certificate": null,
"client_key": null,
"failure_description_url": null,
"server_certificate": null,
"url": "https://sample-alternative-tx-endpoint"
}
curl -i -X POST https://localhost:9411/gateway/set_alternative_endpoint_config -H "Accept: application/json" --data-raw '{
"bearer_token": "123-456-789",
"client_certificate": null,
"client_key": null,
"failure_description_url": null,
"server_certificate": null,
"url": "https://sample-alternative-tx-endpoint"
}'
wget -S -O- https://localhost:9411/gateway/set_alternative_endpoint_config --header="Accept: application/json" --post-data='{
"bearer_token": "123-456-789",
"client_certificate": null,
"client_key": null,
"failure_description_url": null,
"server_certificate": null,
"url": "https://sample-alternative-tx-endpoint"
}'
echo '{
"bearer_token": "123-456-789",
"client_certificate": null,
"client_key": null,
"failure_description_url": null,
"server_certificate": null,
"url": "https://sample-alternative-tx-endpoint"
}' | http POST https://localhost:9411/gateway/set_alternative_endpoint_config Accept:application/json
requests.post('https://localhost:9411/gateway/set_alternative_endpoint_config', headers={'Accept': 'application/json'}, data='{\r\n\n "bearer_token": "123-456-789",\r\n\n "client_certificate": null,\r\n\n "client_key": null,\r\n\n "failure_description_url": null,\r\n\n "server_certificate": null,\r\n\n "url": "https://sample-alternative-tx-endpoint"\r\n\n}')
HTTP/1.1 200 OK
Content-Type: application/json
{"Alternative Strategy config is set"}