Integrating your own StarkEx instance

When you begin working with StarkEx, you receive your own instance of StarkEx on testnet, and your own L1 StarkEx contract.

  • (Recommended) You have used the StarkEx Playground. For more information, see the StarkEx Playground tutorial.

  • You have a dedicated instance of StarkEx for your application. For information on getting your own instance of StarkEx, contact us at

The purpose of this Playground is to facilitate manual experimentation, but it is not optimized for, nor is it intended to be used for, automated testing. When you are ready to conduct testing, including automation, contact us at to set up your own dedicated test instance.

Table 1. A real StarkEx instance compared with the Playground
A real StarkEx instance StarkEx Playground

You are the only operator. You have full control of your StarkEx instance.

There are multiple operators.

You manage the allocation of vault ids (StarkEx Spot) or position ids (StarkEx Perpetual) as part of your application.

The vault or position id that you choose for your transaction might already be occupied by someone else.

You are the only one sending transactions, so you shouldn’t call get_first_unused_tx_id.

StarkEx processes transactions sequentially, based on the value of each transaction’s ID, so the ids in your list of transactions must include all integers in the range of values.

For example, for a list of three transactions, the list of transaction ID values cannot be 0,1,3, it must be 0,1,2. The list can also be non-sequential, such as 0,2,1. If the list doesn’t include an integer, StarkEx stops processing when it reaches the missing ID and waits for it to be submitted.

In order to get the next transaction ID, you must query the StarkEx gateway by calling get_first_unused_tx_id, because other Playground users need to sync the next tx_id.

Be aware that StarkEx does not process two transactions with the same ID and does not process a transaction if the transaction with the previous ID has not been processed.

The time for a transaction to appear on-chain after being submitted can be up to 18 hours.

The time for a transaction to appear on-chain after being submitted is approximately five minutes.

StarkEx for Perpetual Trading

You must implement funding ticks.

Funding ticks are not necessary.

High level steps

  1. For ZK-Rollup and Validium, set up a service to query StarkEx’s availability gateway, compute the new state, and approve it.

  2. For Validium only, set up a Data Availability Committee (DAC).

  3. Be sure to handle requests for alternative transactions to replace invalid transactions in a batch. One invalid transaction can potentially invalidate the entire batch.

  4. Add an event handler to your application to monitor and handle on-chain full withdrawal requests and serve them in a timely manner.

  5. Set up mutual authentication to enable encrypted communication between your application and StarkEx.

  6. For StarkEx for Perpetual Trading, you must begin to implement funding ticks. For information on funding ticks and how to implement them, see Funding tick.

Additional resource
  • More about Validium on StarkWare’s site.