Sample Flow

A sample use case describing how the SDK executes quotes

The following describes an example of a executing quote and how data along with providers are structured for completing an on-ramp transaction.

Use case

A user wants to purchase $50 USD worth of ZK tokens on the ZKsync Era network. They request a quote through the SDK and receive a quote back. The quote will contain information such as:

  • provider: the primary service that the fiat purchase will come from
  • pay: the summary of the purchase request from the user
  • receive: the chain, token and amount the user will receive along with the address the token will be deposited to.
  • paymentMethods: an array of the available payment methods the service provides for fiat purchases.
  • kyc: whether or not kyc is required and what level.
  • steps: the number of steps required to complete the transaction end to end.

Steps

The quote's steps define high level actions that are required to complete the transaction. With the request to purchase $50 USD worth of ZK tokens, the quote returned will have two steps. In this made-up example, we will have two steps since the fiat purchase does not have an option to purchase ZK tokens directly. Our SDK will instead provide a quote option that purchases USDT tokens and then swaps those for ZK tokens.

  • The first step will be a purchase via Kado.money using their on-ramp purchase form for $25 USD worth of USDT.
  • The second step will be a swap from USDT tokens to ZK tokens.

Execution

With the executeRoute function, a quote becomes a route where each step upon execution will include an execution object. Each execution object will have a process array that further breaks down the action to track in detail.

On-ramp purchase via Kado.money

In the first step, the purchase via Kado.money will create an initial process that opens the Kado.money purchase form. The SDK will listen for an update from the purchase form upon completion, receiving an order ID. A second process will then track the status of the order and update whether the transaction has settled or not.

Once the step has succeeded, the execution will move to the next step, the LI.FI token swap.

Token swap with LI.FI

In the second step, the token swap will occur with LI.FI. The first process may differ depending on states like token allowance or chain switching. The following steps will then attempt a transaction signing for swapping USDT tokens to ZK and tracks the status of the transaction.


Made with ❤️ by the ZKsync Community