# ZKBase Introduction

ZKBase is an infrastructure protocol based on Zero-Knowledge (ZK) proof technology, dedicated to providing scaling solutions for mainstream blockchains including Ethereum and Bitcoin. It aims to build a decentralized cross-chain and Layer 2 ecosystem. ZKBase has already implemented several products such as ZKSpace (DEX, ZNS, ZKSea, ZKSquare), ZKSwap (ZKSync), and ZKSwap (ZKFair), offering users a range of services including decentralized exchanges, cross-chain bridges, Layer 2 payments, NFT marketplace, and Layer 2 domain names. In response to the rise of Bitcoin network activities represented by BRC20 Token trading in 2023, ZKBase is set to offer Layer 2 solutions for Bitcoin users, further reducing gas fees and enhancing transaction speed and user experience. It also plans to explore programmable Bitcoin Layer 2 solutions and cross-chain bridges based on ZK.

ZKBase is committed to providing decentralized exchange (DEX) services for multiple Layer 2 public blockchains. ZKSwap is a token swap protocol based on the Automated Market Maker (AMM) model. Utilizing ZK-Rollup technology, it achieves the full functionality of Uniswap on Layer 2, offering unlimited scalability and privacy. ZKSwap provides liquidity providers and traders with a swap infrastructure that supports high-throughput transactions without gas fees.

ZKSwap (ZKSpace) has achieved over $1 billion in Total Value Locked (TVL), saving users tens of millions of dollars in gas fees. It has released tens of millions of dollars in token incentives through innovative models like proof of liquidity and proof of transaction, receiving widespread acclaim. ZKSwap (ZKSync) has become the largest DEX on the ZKSync chain, with tens of thousands of community users and thousands of daily transactions. ZKSwap (ZKFair) was deployed on the mainnet from day one, growing alongside the innovative Layer 2 public chain and its extensive community. The upcoming ZKSwap (Bitcoin) aims to address issues of lack of liquidity, high gas fees, and slow speeds in BRC20 token trading, creating a dedicated BRC20 Layer 2 exchange that ensures a smooth trading experience while safeguarding user assets with advanced ZK and blockchain technology.

In the future, ZKBase plans to further explore the programmability of the Bitcoin network and decentralized cross-chain bridges, enabling safe and convenient cross-chain transactions for BRC20 and other Bitcoin network assets to other public blockchains. The ZKBase team will continue to advance the technical development and application of a complete Layer 2 ecosystem on Bitcoin, creating more use cases for user assets and offering increased composability.


# How to convert your ZKS to ZKB

In 2023, with the continuous prosperity of the BTC and BRC20 ecosystems, the ZKSpace brand is being rebranded as ZKBase. This transformation brings about a new product roadmap and vision, entering the Bitcoin ecosystem and exploring Layer2 services spanning both Bitcoin and Ethereum. Concurrently, we have introduced the ZKS token acceleration deflation plan. In December 2023, 400 million unissued ZKS tokens were burned, combined with ongoing platform fee repurchases leading to a circulating supply reduction to less than 600 million. To align with the new brand, ZKBase, and to enhance product planning, we plan to conduct a 1:1 token swap from the existing ZKS token to the new ZKB token.<br>

### Token Information

#### Old Token

Token Name: ZKSpaceToken&#x20;

Symbol: ZKS

Network: Ethereum Mainnet

Contract Address: 0xe4815AE53B124e7263F08dcDBBB757d41Ed658c6Total Supply: 598M

#### New Token

Token Name: ZKBase

Token Symbol: ZKB

Network: Ethereum Mainnet

Contract Address: 0xBBBbbBBB46A1dA0F0C3F64522c275BAA4C332636Total Supply: 600M (2M pending for burning)

### Swap Rules:

Holders of ZKS can interact with the token swap smart contract through the provided frontend to exchange ZKS for ZKB at a 1:1 ratio. The swapped ZKS will be sent to a burn address for destruction. The token swap smart contract is deployed on the Ethereum mainnet and zkSync Era, supporting swaps on both networks. ZKB on zkSync Era can be cross-chain bridged to the Ethereum mainnet.

### Convert Tutorial:

Step 1: Visit the page from the official website(<https://zkbase.org>).

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FWlIyN3CqZUZnqxCiKLNy%2F1.png?alt=media&amp;token=e397eab6-bffa-4ecb-a373-63a529e0ff61" alt=""><figcaption></figcaption></figure>

Step 2: Choose the network (Ethereum Mainnet or zkSync Era) and connect your wallet.

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FcJqpuxpOdewD4NDm3edt%2F2.png?alt=media&amp;token=eae0c365-81a4-4f76-ba50-2672167bb459" alt=""><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FSQYhS5EDvIWWicHGMtfm%2F3.png?alt=media&amp;token=d5e428b6-34cb-4709-bef5-3f354ff56dd8" alt=""><figcaption></figcaption></figure></div>

Step 3: Authorize transfer permissions to the contract. Note that the displayed ZKS balance is for the selected chain.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FfVjd6sXHJYJCVEv6gTKU%2F4.png?alt=media&amp;token=92c10a0b-638d-497a-8d19-39241f12a178" alt=""><figcaption></figcaption></figure>

Step 4: Convert ZKS to ZKB.

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FDRUeqCUhOb0geubiLk5v%2F5.png?alt=media&amp;token=e1d685ed-9e1b-4ba4-86bf-aaa43136292d" alt=""><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F146jAycNI0dDL5qKvh1D%2F6.png?alt=media&amp;token=f2c7d6e2-bead-4b7d-be5b-1017a5740ac0" alt=""><figcaption></figcaption></figure></div>

Step 5: Import ZKB into your wallet.

* Method 1: Import it into the Successful Convert.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FI2ksfXAnghZzZkSuxtXB%2F7.png?alt=media&amp;token=b0e0b442-e90a-482d-9918-15df1dac0979" alt=""><figcaption></figcaption></figure>

* Method 2: Import it into the wallet interface (eg: Metamask). ZKB Contract Address: 0xBBBbbBBB46A1dA0F0C3F64522c275BAA4C332636

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F044u4QGEBUgSoPbyfSHv%2F11.png?alt=media&amp;token=37d75479-94ca-4fc6-904d-04543cc9f420" alt=""><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FXt7OV3Zro0w8FQPOGLKt%2F12.png?alt=media&amp;token=096f0fb6-aaf9-45e6-a278-ca3dd3d62aac" alt=""><figcaption></figcaption></figure></div>

### What's Next

We will introduce ZKBSwap, a platform focused on BRC20 token trading, as the first step in exploring BTC Layer2 solutions. ZKB will also upgrade to become the platform token for ZKBSwap. We will provide an ERC20-BRC20 cross-chain solution, enabling ZKB holders to benefit from both ETH and BTC dual-chain ecosystems. Future transaction fees on the dual-chain platform will continue to be used for ZKB repurchases and burns, empowering ZKB holders further. Stay tuned for more details on BRC20 ZKB token specifics.\
For any inquiries, feel free to contact us through social media and community channels for the latest updates.


# ZKSpace Documents Archive


# Introduction

Based on ZK-Rollups technology, L2 Labs has launched ZKSpace, a full-featured protocol of Layer-2, including DEX, payment, and NFT function, and it transfers all tokens (including protocols ERC20 and ERC721) onto Layer-2 using ZK-Rollups technology. The consistent state of Layer1 and Layer2 is guaranteed based on continuously generated zero-knowledge proofs, so as to make all token swaps, transfers, and NFT minting and trading on Layer 2, realizing real-time trading with low Gas fees (no need to wait for one-block confirmation). As well, it also has infinite scalability, getting rid of the limit on TPS and one-block confirmation on Ethereum. In addition, users can enjoy CEX and a smooth trading experience like traditional e-commerce platforms and can guarantee asset security of their own in real-time.

ZKSwap is a token swap protocol based on Automated Market Maker (AMM). Through ZK-Rollup technology, the full set of Uniswap functions are realized in Layer-2, while providing unlimited scalability and privacy. ZKSwap **offers swap infrastructure and transactions with ultra-high throughput and zero gas fees to liquidity providers and traders.**

## ZKSpace's Features

ZKSwap, a decentralized exchange based on ZK-Rollups under the ZKSpace protocol, has implemented the complete function of Uniswap on Layer2, reducing Gas fees to a tenth of a percent while ensuring the same security as Layer1.

At the moment, most decentralized exchange DEXs such as Uniswap differ from centralized exchanges such as Huobi and OKEx in incorporating automated market makers and replacing manual quotations with established algorithms. As such, decentralized exchange can remove centralized matching and clearing while eliminating the market maker in the transaction. Thus, they can provide users with highly secured and confidential transactions.

However, due to limitations of blockchain technology, long block generation time, and slow confirmation speed of the Ethereum main chain, decentralized exchanges are facing pain points such as low throughput, slow processing speed, and high Gas Fees. These problems directly result in a bad overall user trading experience and lead to the fact that decentralized exchanges can not replicate the centralized exchanges experience.

But ZKSwap carries out the exchange logic of traditional decentralized exchanges on Layer-2 through ZK-Rollups technology, so that all exchanges are completed on Layer-2, reducing the user's transaction costs while ensuring the overall transaction experience. Compared to traditional DEX, ZKSwap has the following advantages:

**Low Gas Fee**: Instead of generating Gas Fee from transactions on traditional Dex (Gas Fee will continue to increase as the Ethereum price increases), ZKSwap transactions on Layer-2 require low Gas Fee, which greatly reduces transaction cost for users.

**High TPS（Transaction Per Second):** Hindered by TPS limitations on Ethereum, traditional Dex such as Uniswap has an obvious bottleneck in transaction numbers and capacity per second. Through optimizing GPU, ZKSwap can conduct hundreds and thousands of TPS with the trustless method. While having enough machines to support expansion, ZKSwap's TPS can theoretically reach 6000.

**Real-time transaction**: All transactions on ZKSwap are transferred to Layer-2 and are valid for real-time transactions, users DO NOT need to wait for the confirmation time of a block.

In the coming days, the implementation of ZKSea will greatly optimize the users’ experience when minting and trading NFTs and can return the pricing authority of NFT products to the artist and the market, which is unlimited for the high gas fee. We will also open the NFT minting interface to all NFT platforms.

The first version of ZKSea will possess the following functions:

1. Mining NFT with zero Gas fee on the Layer-2 network;
2. For functions of trading and transferring function with zero gas fee of NFT on layer-2, thousands of TPS can be reached theoretically;
3. NFT can be deposited and withdrawn between Ethereum Layer-1 and Layer-2 networks;
4. There is an NFT storefront, supporting free transactions between users on the Layer-2 network.

In the future, the ZKSpace protocol can further improve the Layer-2 performance and will issue more products to enhance the user experience, extending the ecosystem environment of Layer-2.


# Definition

## 1.Definition

L1: Short for Layer-1, generally considered as the main chain of Ethereum.

L2: Short for Layer-2, it is a capacity expansion solution based on the Ethereum main chain.

L2 deposit: Transfer the token from the Layer-1 account to ZKSwap Layer-2 account.

L2 Withdrawal: Retrieve the token from the Layer-2 account and send it to the Layer-1 account.

L2 transfer: Complete the transfer of token on Layer-2 without gas fees.

TPS: The number of transactions that can be processed per second.

ZKSwap: Layer2 token swap protocol based on ZK-Rollups.

ZK-Rollups: ZK-Rollups is a popular Layer 2 scaling solution. Its basic idea is to scale the network by aggregating multiple transactions and verify the proof on-chain. ZK-Rollups analyzes and verifies these aggregated transactions through smart contracts, and uses zero-knowledge proof technology to put the proof of aggregated transactions on-chain, thereby reducing the data that needs to be stored on-chain. All funds are locked in the smart contract, and most of the calculations and storage are done off-chain.

Zero-knowledge proof: The prover can convince the verifier that a certain assertion is correct without providing any useful information to the verifier. Zero-knowledge proof is essentially an agreement involving two or more parties, which is a series of steps that two or more parties need to take to complete a task. The prover proves to the verifier and makes him believe that the prover knows or possesses a certain message, but the certification process cannot be leaked to the verifier.

Uniswap: is an automated liquidity protocol powered by a constant product formula and implemented in a system of non-upgradeable smart contracts on the Ethereum blockchain. Users can create a liquidity pool by providing a certain percentage of ETH and any other ERC20 asset. One liquidity pool reserves ERC20 tokens and provides liquidity for the transactions between these two assets. In return, all liquidity providers will split 0.3% of the transaction volume as a liquidity provider fee. In Uniswap, the first liquidity provider needs to set the ratio of the two assets in the liquidity pool. The automated market maker algorithm will ensure that the product of the two assets before and after each transaction remains constant.

Create a Liquidity Pool: In Uniswap, each trading pair has only one liquidity pool, which is generally created by the first liquidity provider. For example, a liquidity provider creates an ETH-ZKS liquidity pool, and then adds liquidity. The initial amount of ETH deposited is x0, the number of ZKS stored is y0, and x0 ∗ y0 = c0. Here ZKS can be any ERC-20 token.

Liquidity Token: Liquidity Provider (hereinafter referred to as LP) will obtain the Liquidity Provider Token, (hereinafter referred to as LP Token or LT), which is used to represent the share of LP in the current liquidity pool. LP Token is an ERC-20 token that can be transferred without removing the liquidity of the liquidity pool. Each liquidity pool has a corresponding LP Token.

Create Liquidity: When adding liquidity to an existing pool, users must add pair tokens proportional to the current ratio.

Remove Liquidity: Liquidity providers can remove liquidity by burning their LP Token in the liquidity pool contract and retrieve the corresponding shares of two tokens from the pool.

Swap: After the liquidity pool is created and liquidity is injected, users who hold ETH or ZKS can start swapping in the liquidity pool.

## 2.Layer 2 Concept Introduction

DeFi and NFT applications on Ethereum provide numerous revenue opportunities for the market, but as cost increases, the industry has begun to turn its attention to retail investors. As DeFi projects become more active, the load of contemporary protocols is very limited. Therefore, many Layer 2 protocols have emerged. The main goal of these protocols is to reduce the number of transactions on the Ethereum blockchain by transferring transaction activities to other places, while still using the main chain as a guarantee of security. For example, **state channels, sidechains, Plasma, and Rollup**. The core idea of all Layer 2 solutions is to allow multiple participants to interact securely in some way, without the need to publish transactions on the main chain (ie Layer 1), but to a certain extent, the Ethereum network is still used as arbitration to ensure safety. Different Layer 2 solutions have different characteristics and advantages and disadvantages.

The following articles elaborate on the current mainstream Ethereum layer 2 scaling solutions.

[Making Sense of Ethereum’s Layer 2 Scaling Solutions: State Channels, Plasma, and Truebit](https://medium.com/l4-media/making-sense-of-ethereums-layer-2-scaling-solutions-state-channels-plasma-and-truebit-22cb40dcc2f4)

[Overview of Layer 2 approaches: Plasma, State Channels, Side Chains, Roll Ups](https://nearprotocol.com/blog/layer-2/)

[Optimistic vs. ZK Rollup: Deep Dive](https://medium.com/matter-labs/optimistic-vs-zk-rollup-deep-dive-ea141e71e075)


# ZKSpace Trading Rules

pace

## **General Rules:**

The platform supports four Fee Token(ETH, ZKS, WBTC and USDT). Users can choose one of them on the setting page as the platform fee to withhold the fee and Gas fee to be paid in various scenarios. The details of each fee are as follows (The Gas fee for each operation is determined according to the cost for putting data on blockchain of ETH main network).

## **L2 Wallet:**

**Deposit:** Support deposit from my Layer1 wallet, or deposit from other Layer2 accounts. ZKSwap does not charge any deposit fees.&#x20;

**Send:** Support transfers to Layer2 wallets from any ERC20 address. Each transfer will be charged for $0.5 equivalent on-chain Gas fee.

**Withdraw:** Withdraw asset to your Layer1 wallet by default, and you can also withdraw asset to any ERC20 address. If you withdraw ETH to the exchange address, please make sure it supports the type of transaction (internal transaction) transferred from the contract. ZKSwap will charge $30 equivalent tokens as Gas fee when you withdraw any token.&#x20;

**Total Value Locked:** Including L2 Assets Details and L2 Pool Details.

**L2 Assets Details:** ZKS sort first by default, other tokens display the quantity and value in descending order of the value of the assets in the wallet (priced in USDT).

**L2 Pool Details:** According to the value of different LP Tokens in the wallet (priced in USDT), the quantity and value are displayed in descending order.

## **L2 Swap:**

**Liquidity:** Liquidity value of the fund pool.

**Price:** the current price of the token/USDT.

**Slippage Tolerance:** Due to the limited depth of liquidity pool, swap, adding liquidity, or removing liquidity will impact the current price. Your transaction will revert if the price changes by more than this percentage.

**Est. Deal Price:** Due to the limited volume of the fund pool, exchange, addition, or removal of liquidity will impact the current price, causing the transaction price to deviate from the current price.

**Price Impact:** Due to the limited volume of the fund pool, the exchange will impact the current price. The expected price fluctuation is the percentage difference between the current price and the transaction price.

**Transaction Fee:** The ZKSwap agreement will charge 0.3% of all Layer2 Swap transactions as the transaction fee.Among them, 0.25% will be automatically allocated to the liquidity provider, and the other 0.05% will be used as the protocol fee. All protocol fees (100%) will be used as long-term incentive for the project, and ZKSwap officials will not receive any transaction fees.

**Gas fee:** Each Swap transaction needs to pay $1 equivalent Gas fee, which is used to amortize the cost of aggregating and packaging the results of multiple transactions on the platform and putting data on ETH blockchain.

**Input:** Please enter the number of tokens you are willing to pay to exchange for the corresponding tokens.

**Minimum Received:** The minimum amount you will receive after the swap has been submitted. The transaction will revert if there is a large, unfavorable price movement before your submission.

**Slippage Setting:** Slippage can be set.

**Status:** Submitted/Deal/Success

**Status Description:** “Submitted“ means that the transaction has been sent to the Layer2 network. “Deal” means that the Layer2 network relevant amount change may have taken effect. “Success“ means that the transaction has completed ZK-proof and been submitted to the Ethereum Layer1 network.

**Minimum Amount to be Exchanged:** After the exchange is successful, the token value you will receive must be greater than 10 USDT, otherwise, the exchange cannot be submitted.

## **L2 Pool:**

**Add/Withdraw Liquidity:** Each addition of liquidity needs to pay $1 equivalent Gas fee. Each removal of liquidity needs to pay $50 equivalent Gas fee.

## **Mining:**

**Proof-of-Gas Mining:** The official will withdraw ETH from the fund pool participating in PoG mining at a random time every day according to the gas cost consumed by ZKSwap, consume the user's ETH according to the proportion of the user's deposited ETH in the fund pool, and generate ZKS prize pool of the day according to the official ETH value\*125%The Prize will then be distributed to users in proportion.

**Deposit ETH for PoG:** Only ETH in the Layer1 wallet can be deposited to the smart contract address for mining.

**Withdraw to Wallet:** Withdraw the principal (ETH) or reward (ZKS) from the smart contract to the Layer1 wallet.

**PoG Reward Balance:** The daily gas mining rewards will be accumulated in the reward balance. After each deposit of ETH, there will be a 24-hour lock-up period for the reward balance, after which the reward can be withdrawn at any time.

**Proof-of-Staking Mining:** If your ZKS is in the Layer2 wallet, please withdraw it to the Layer1 wallet before participating in the PoS event. Please note that you will not be able to get the staked ZKS back until the PoS event ends.

**Proof-of-Liquidity Mining:** ZKSwap's liquidity providers can automatically participate in the liquidity mining activities, splitting the ZKS prize pool according to the ratio of the provided liquidity value to the liquidity value of ZKSwap Layer2 pairs, the mining rewards will be distributed to your L2 wallet account every day.

**Proof-of-Transfer:** If you participate in the L2 swap of the following transaction pairs, you can divide up the mining reward according to the swap amount, and the reward will be automatically distributed to your L2 wallet account every day. The total reward for daily mining is the equivalent ZKS of the pair's daily transaction fee\*90%. To prevent malicious scalping, a single pair has a daily 2000/1000 upper limit.

## **ZKSea:**

**NFT creation:** Users have the freedom to create NFT on the ZKSea platform for a $5 Gas fee per creation.

**NFT for sale in mall:** Users can customize the price of a piece of NFT to pending order in the mall for sale, and no Gas fee will be charged for pending order. After the transaction, 2.5% of the pending order amount will be charged as the platform fee.

**Cancellation of pending order NFT:** When the NFT submitted for sale has not been sold yet, the user can cancel the pending order NFT. This will be charged $1 equivalent Gas fee.

**NFT purchase:** Purchasing NFT from the mall requires a $10 equivalent Gas fee.

**NFT Transfer:** NFT can transfer freely on ZKSea and charge $1 equivalent Gas fee for each transfer.

**NFT Deposit:** Users can deposit the NFT from ETH main network to ZKSea to enjoy the ultra-fast and low-cost Layer2 service. ZKSea does not charge any deposit fee.

**NFT Withdrawal:** Users can withdraw any NFT on ZKSea to Layer-1. If the NFT is created on ZKSea platform, $120 equivalent Gas fee will be charged for withdrawal. If the NFT comes from Layer-1 recharge to ZKSea platform, $30 equivalent Gas fee will be charged for withdrawal.


# Governance


# Community Governance Policy

## **Governance Structure：**

Community Governance consists of three parts：

* **Portals**: You can access details on the Wiki community governance page through the official website, APP, and web browser.  &#x20;
* **Forum**: On the forum, users can discuss the content of the proposal, the results of the proposal, and the implementation details.
* **snapshot platform**: users will use the governance tool Snapshot to post proposals and vote.           &#x20;

## **gZKS Rights and Interests ：**

**gZKS Rights**：\
1\. Users can participate in community governance with gZKS, including the right to propose and vote.\
2\. Users with 50,000 or more gZKS can initiate proposals.\
3\. There is no threshold for participation in voting, and votes are counted by the number of gZKS, with a minimum of 1 gZKS required for a single vote.

**gZKS Generation rules** ： gZKS is generated by a 360-day ZKS Proof-of-Staking contract. You can get gZKS only when the remaining Proof-of-Staking time of the 360-day lock-up contract is greater than or equal to 180 days. When the remaining time of the existing 360-day PoS mining activity is less than 180 days,ZKSwap team will open a new 360-day PoS contract. By then, users can lock ZKS in the new 360-day PoS contract to obtain gZKS.

**gZKS Issuance rules** ：Users who participate in the ZKS 360-day PoS mining will receive the corresponding amount of gZKS airdrops at the L2 address weekly. The amount of gZKS obtained is determined by the amount and time of the user's actual locked ZKS. Users who lock up for 360 days can get the same amount of gZKS for locked ZKS, which will decrease linearly with the actual PoS time to half the amount of gZKS (half the amount of gZKS can be obtained after 180 days of lock up, but not for less than 180 days. To obtain gZKS, you need to participate in the new 360-day PoS and mining activity).

For example: when there remain 270 days till the 360-day PoS contract expires, if the user chooses to lock 100 ZKS, the corresponding 75 gZKS can be obtained in the L2 account.

**gZKS Expiration**：The valid period of gZKS generated by the existing ZKS360-day PoS contract is 720 days.

## **Governance Process**：

**1.Community Discussion：**&#x55;sers can publish community governance-related posts in the corresponding section of the forum to discuss, and generate preliminary ideas and opinions on the proposal.

Forum Link： [https://forum.zks.org](< https://forum.zks.org>)

**2.Initiating a proposal：**&#x54;he initiator needs to pledges 50000 gZKS on the snapshot to initiate a proposal.

**3.Review on the Snapshot ZKSwap governance page:** we will publish links to the Snapshot page on the ZKSwap forum once the gZKS is minted.

Snapshot governance link： <https://snapshot.org/#/gzks.eth>

**4.Voting：**&#x41;ny gZKS holder can vote on the snapshot proposal voting page. The process is carried out on-chain to ensure openness and transparency.

**5.Result announcement：**&#x5A;KSwap forum administrators will publish the results of valid proposals in the corresponding sections of the forum, and synchronize the implementation plan and progress.

## **Proposals：**

The proposal can be passed as long as it has enough net votes to support it. Including but not limited to the following scope:

**1.Token Listing：** Proposer can propose to officially launch any ERC20 token or trading pair on ZKSwap. Once passed, ZKSwap will complete the listing or add trading pairs within 7 days after the proposal is passed.

Pass conditions: 500 thousand gZKS

**2.Airdrop：** Proposers can propose for airdrops to any DEFI project user with certain rules. Once passed, the official will airdrop a certain amount of ZKS to the Layer2 addresses of eligible users to incentivize users to use ZKSwap. The amount of subsidy is determined by Gas on the ETH chain during the airdrop (subsidies for deposit fees).

Pass conditions: 1 million gZKS

**3.Liquid mining activities：** Proposers can propose to launch liquid mining activities of any currency pair. Once passed, ZKSwap will add the currency pair in the next liquidity mining activities, and the mining rewards will be determined based on the average revenue of the platform's liquidity mining.。

Pass conditions: 1 million gZKS

**4.Modify governance rules：**&#x50;roposers can also propose to make amendments to adjust the community governance policies and approval threshold. ZKSwap will amend the community governance rules promptly.

Pass conditions: 3 million gZKS

**5.Parameter adjustments such as fee rates：** Proposers can propose to modify the fee rate parameters set by the platform, such as the liquidity fee that needs to be provided for exchange, the withdrawal fee, daily free transfers, the number of times to remove/add liquidity for free and the amount charged once free limits have been reached, etc. Once passed, ZKSwap will optimize the relevant rates in the next iteration.

Passing conditions: 5 million gZKS

**6.Modification of economic model parameters:** Proposers can propose to modify the ZKS token release economic model, including but not limited to various types of mining distribution, output halving over time, and the repurchase and destruction of ZKS with handling fees. Once passed, ZKSwap will make relevant adjustments in the next version or event while announcing the progress in time.

Pass conditions: 10 million gZKS

**7.Future technical roadmap:** Uers can propose future technical route development and modify the ZKSwap technical roadmap, including but not limited to NFT launching and mintage, Layer2 cross-chain support, EVM support, and Layer2 ecosystem expansion, etc. Once passed, the ZKSwap team will adjust the technical route and invest in R\&D in a timely manner and regularly publicize the progress.

Pass conditions: 10 million gZKS


# Proposal Requirement and Template

**All ZKSwap Improvement Proposals should follow the template guidelines:**

### **1.Proposal Requirement：**

1: The title should be concise and the proposal should only be written in English or Chinese.

2: Start the proposal with a short summary or bullet points.

3: Provide an explanation: Clearly describe what will be implemented if the proposal is executed.

4: Give the motivation: Reason for your proposal.

5: Add specifications: Provide a further explanation if necessary.

6: Give the Pros and Cons of your proposal.

7: Option to include a poll for voting.

Please carefully consider your proposal before posting on our [forum](https://forum.zks.org/), thank you!

### **2.Proposal Template：**

**Title：**

**Summary：**

**Explanation：**

**Motivation：**

**Specifications：**

**Pros：**

**Cons：**

**Poll：**


# FAQ

## 1. Why does ZKSwap develop Uniswap in Layer 2 ？

Since 2019, the blockchain industry has undergone breathtaking changes. Decentralized finance(DeFi) continues to grow at an exponential rate. The Total Value Locked in different DeFi protocols has exceeded 70 billion U.S. dollars. With the continuous development of numerous on-chain assets and off-chain assets going on-chain, we believe that the Total Value Locked in DeFi protocols will soon exceed 100 billion U.S. dollars. These on-chain assets require fast, frictionless, trust-free, and real-time exchange services, which has led to the rise of new decentralized exchange(DEX) protocols such as Uniswap.

Although the new DEX model spearheaded by Uniswap has achieved significant development, it still has obvious drawbacks. First, the high gas fee of dozens of dollars per transaction hinders new users to entry; second, every transaction and every execution needs to wait for at least one block to confirm, which gives an unsatisfactory experience; and third, subject to the limiting TPS of Ethereum, Uniswap has a clear bottleneck in transaction numbers and transaction capacity per second. Those drawbacks are not unique to Uniswap. They are common issues faced by all DEXes.

ZKSwap (a ZK-Rollups based token Swap protocol) is a brand-new exchange protocol based on ZK-Rollups technology. Through Zk-Rollups technology, all ERC20 tokens are transferred through Layer2, and the consistent state of Layer1 and Layer2 is guaranteed based on continuously generated zero-knowledge proofs. This solution allows all transactions and swaps to execute on Layer 2, achieving real-time swap with zero gas fees, unlimited scalability, removing the constraint from Ethereum's TPS. The user no longer has to wait for the one-block confirmation time for each transaction. ZKSwap enables a DEX to provide the smooth user experience of a centralized exchange(CEX) while allowing the users to have full custody over their funds. We believe that ZKSwap is the future form of a token trading platform. It will trigger a significant evolution of all existing DEX and CEX.

## 2. Zkswap's advantages compared to Uniswap

Although new Dex such as Uniswap has made great progress, there remain considerable amounts of shortcomings. ZKSwap's has the following advantages compared to Uniswap:

**0 Gas Fee:** Compared to dozens of dollars worth of Gas Fees resulted from transactions on traditional Dex (Gas Fee will continue to increase as the price of Ethereum increases), ZKSwap transactions on Layer-2 requires zero Gas Fee，which greatly reduces transaction cost for users.

**High TPS（Transation Per Second）**: Hindered by TPS limitations on Ethereum, traditional Dex such as Uniswap has an obvious bottleneck in transaction numbers and capacity per second. Through optimizing GPU, ZKSwap can conduct hundreds and thousands of TPS with the trustless method. In the case of having enough machines to support expansion, ZKSwap's TPS can theoretically reach 6000.

**Real-time transaction**: All transactions on ZKSwap are transferred to Layer-2 and are valid for real-time transactions, users DO NOT need to wait for the one-block confirmation time.

## 3. The difference between ZKSwap and Centralized Exchange (CEX)

The centralized crypto exchange, represented by exchanges such as Binance, Huobi, OKex, etc., has gathered a huge number of users and transactions. The main differences between ZKSwap and centralized exchanges are as follows:

**From the perspective of asset security**, the CEX wallet stores and manages all users’ assets. Due to a large number of funds, it is easy to attract hackers. Once a problem occurs, almost all users will suffer losses; in ZKSwap, users’ Assets are not stored on the platform but managed by smart contracts. During the transaction, the platform does not touch the user's assets. Each transaction requires users to complete the confirmation with a private key signature, and the swap of assets is directly transferred to the account L2 wallet.

**From the perspective of asset control**, in CEX, user assets are controlled by the platform, and users need to transfer their assets to the wallet of the trading platform. The asset custody function of the centralized trading platform is just like a bank. The user deposits the money in the bank, and the bank gives the user an account to record the user’s funds. The bank has absolute control over the user’s funds; on ZKSwap, the user’s assets are completely in the control of the user. ZKSwap does not provide fund custody services, so it cannot control or transfer users' funds. As a decentralized exchange in Layer-2, ZKSwap has passed the security audits of three major audit institutions (ABDK, Certik, and SlowMist) for its contracts and circuit codes. Users control their own private keys and their assets are safe and controllable.

**From the user registration process**, in CEX, users register for an account and set a password to enter the exchange. This process generally requires KYC. Corresponding materials need to be submitted to be reviewed. On ZKSwap, users can use ZKSwap without KYC by connecting the Ethereum wallet to the ZKSwap platform, making the process faster and more convenient.

**From the transaction process**, CEX transactions are completed through order book matching; ZKSwap uses the automatic market maker AMM model, which has obvious advantages in user asset utilization efficiency and transaction depth. The transaction process is executed by the smart contract, without any third party acting as an intermediary.

## 4. Where are the user's funds entrusted?

The user's assets in ZKSwap Layer-2 are entrusted in the smart contract and are completely under their own control. Except for the user who owns the account's private key, other third parties cannot control or transfer the user ’s assets. Even if the project team stops the service, the users can still retrieve the assets autonomously from the smart contract.

## 5. The difference between ZKSwap and Loopring Protocol

The main difference between ZKSwap and Loopring is areas of product route, technical details, and user experience.

**In terms of product design**, Loopring is a Layer-2 DEX based on the order book model, and it has also begun to explore Layer-2 DEX based on the AMM model. ZKSwap mainly focuses on Layer-2 DEX based on the AMM model and hopes to build more Layer-2 infrastructure in the future.

**In terms of technical details**, Loopring uses Groth16's zero-knowledge proof algorithm, and the circuit needs to be reset every time a trading pair is launched. ZKSwap is based on the newer Plonk zero-knowledge proof algorithm, which is more efficient and is capable of updating the trusted settings without having to update the circuit every time.

Overall, Layer 2 is a track with high opportunities, and Layer 2 projects are too few, not too many. We believe that more and more projects will enter this track in the future and bring more innovation and diversity into the ecosystem. ZKSwap hopes to build a complete Layer 2 ecosystem together with these projects.

## 6. How to trade on ZKSwap

After the user connects the wallet to zks.app, deposits assets to the second-tier account of ZKSwap, he can then start trading. For the specific transaction process, please refer to: [ZKSwap Web app Tutorial](https://zks.app/docs/tutorial-en.pdf)

## 7. Why can’t L2 transfers be directly transferred to the exchange's(Binance, Huobi, etc.) address?

Since the exchange currently does not support ZKSwap Layer-2 transfer, users should not use the L-2 transfer function to transfer funds to the exchange address. In the future, we will seek the L2 transfer cooperation with the exchange, and support users to transfer ERC20 tokens to the exchange address in real-time through ZKSwap with 0 Gas fee.

## 8. Can ZKSwap's withdrawal be faster?

The recent upgrade on ZKSwap Layer2 system has optimized the ZKSwap withdrawal function. The withdrawal time from Layer 2 to Layer 1 processed by the smart contract on ZKSwap will be directly shortened from 30-60 minutes to 20-40 minutes. In the future, we will continue to optimize technology and iterative products to provide better service and experience to ZKSwap users.

## 9. Why is there a minimum account balance requirement before L2 transfer and swap can be performed?

Since L2 transfers and transactions on ZKSwap need to generate zero-knowledge proofs and send them to Layer 1 to ensure asset security, and the data on-chain process will generate a certain amount of Gas fees. To limit the increase in ZKSwap operating costs caused by malicious attacks, we limit the minimum balance of the account to reduce the risk of attack. Therefore, users need to deposit at least 50ZKS or the equivalent of 200 usdt tokens into the L2 account before performing L2 operations.

## 10. Why did ZKSwap choose the ZK-Rollups technical route?

After a lot of research and testing, the ZKSwap project team found that ZK-Rollups is the best option for ETH scaling. ZK-Rollups adopts the popular Rollups expansion idea to realize the expansion of Layer-2. At the same time, ZK-Rollups uses zero-knowledge proof technology to upload calculation proofs on Layer-2 in real-time, achieving almost the same level of security as Ethereum Layer-1 network.

ZK-Rollups has a great advantage in finalizing transactions, and the withdrawal time has been significantly shortened, which greatly improves the user experience. Also, with the upgrade of computer hardware and the development of zero-knowledge proof algorithms, the performance of Layer-2 can be further improved on the existing basis. Therefore, ZK-Rollups has achieved a good balance in terms of scalability, security, usability, and performance, and is currently the most suitable layer 2 solution for building DEX.

## 11. What is the current TPS of ZKSwap? How to achieve scalability? Why is it said that due to the overall consensus of Ethereum, spending more money can not increase TPS?

Compared with Ethereum's 10-20 TPS, ZKSwap's current TPS is about 100 transactions in 15 seconds, and theoretically, TPS can reach more than 6000. Because all transactions occur in Layer 2, ZKSwap has unlimited scalability. In the future, ZKSwap will focus on the following areas to improve scalability:

1. **Expand a large number of prover nodes**
2. **Increase the chunk value of each block to increase the number of fast packaged transactions**
3. **Optimize the circuit design, optimize the GPU**

Ethereum's consensus has throughput limitations, and throughput depends on block size and block time. The larger the block, the shorter the block time and the greater the throughput. However, larger blocks are not conducive to the decentralization of nodes, and reducing block time will increase the probability of chain forks. Simply increasing the block size or reducing the time between block generations cannot solve the problem, because the block needs time to transmit and verify. If the block is too large, it will cause increase the inconsistency of the network nodes (more forks) , which seriously affects safety.

## 12. How to list tokens on ZKSwap?

In the future, ZKSwap will open community governance. The community can propose to initiate a token listing application. Users who participate in ZKS's long-term PoS mining activities can vote on the token listing proposal with the gZKS obtained from the PoS mining activities.

## 13. How does ZKSwap L2 account work?

At present, ZKswap's products including : layer2 wallet and Layer2 AMM swap protocol. The wallet is used to store and user's Layer 2 assets, while the AMM protocol is used to conduct swap and transactions. This is similar to the wallet + transaction function of a traditional centralized exchange. Layer 2 wallet and Layer2 AMM swap protocol are indispensable to complete the full Layer 2 transaction process.

## 14.How to transfer ETH and ERC20 through ZKSwap through web3 wallet?

Currently, ZKSwap supports Metamask, imToken, TokenPocket, and Bitpie wallets to transfer ETH and ERC20 tokens through ZKSwap, and users do not need to pay any gas fees. Please download the wallet and set up the connection. After that, ZKSwap will continue to connect to more wallets for users to use. See the specific ZKSwap tutorial:

[ZKSwap App on Ethereum Mainnet Tutorial](https://zks.app/docs/tutorial-en.pdf)

## 15. How does ZKSwap's system work?

The ZKSwap system consists of on-chain smart contracts, an off-chain ZKSwap server, the zero-knowledge proof system, and the front-end user interface.

[![ZKSwap System Archtecture](https://camo.githubusercontent.com/382e0300454ee87ac98872abb3a2bfdfd86d6d7cca75a0310e1235ebd5b0ec42/68747470733a2f2f7a6b732e6f72672f696d616765732f626c6f672f31312f312e706e67)](https://camo.githubusercontent.com/382e0300454ee87ac98872abb3a2bfdfd86d6d7cca75a0310e1235ebd5b0ec42/68747470733a2f2f7a6b732e6f72672f696d616765732f626c6f672f31312f312e706e67)

**ZKSwap Smart Contract**

ZKSwap will deploy a series of smart contracts on the Ethereum blockchain to store the tokens deposited by users while recording and verifying Layer 2 status updates and related proof. Those smart contracts are the key hub connecting on-chain and off-chain.

**ZKSwap Layer 2 Server**

The ZKSwap server is the module that processes all transactions off-chain. The ZKSwap server can use the WebSocket to interact with the user, and monitor transactions on the Ethereum blockchain. All valid transaction requests will be put into the ZKSwap mem pool and processed by the Swap Engine. The transaction types in the mem pool are the same as the transaction types of Uniswap. The Block Proposer will roll up the transactions and generate a new block. The State Keeper will update the status of all tokens on Layer 2. The State Keeper will send the state to the Commiter, which is responsible for communicating with the Prove Server, obtain the proof of the corresponding transaction, and finally send the state and the corresponding SNARK proof via Ethereum sender to the ZKSwap smart contract on-chain.

**Plonk Zero-knowledge Proof System**

ZKSwap’s zero-knowledge proof system adopts a distributed architecture and uses the latest zero-knowledge proof algorithm PLONK to generate proofs. The Prove Server supports multiple Provers. Multiple Provers actively query the proof tasks in the Prove Server and send them back to the Prover Server after generating the proof. PLONK’s global trust setup only needs to be generated once, and the circuit can be greatly reused within a certain range, reducing the threshold for using zero-knowledge proofs.

**ZKSwap state tree**

The status tree of the ZKSwap system records the balance of all accounts in the current system. The state tree of ZKSwap is a Merkel tree with a height of 34. The child nodes of the Root are all account nodes (24 levels) in the system. There are two types of account nodes:

* Ordinary account node: to record the status of all tokens in the account. Ordinary account nodes can have any number of leaf nodes (10 levels), each leaf node represents a type of token and its amount; there can’t be repeated token types within one account.
* Pair account node: to record the status of the liquidity pool of a certain pair of assets ZKSwap. The Pair Account Node contains only two leaf nodes. Each leaf node represents the balance and type of one token in the liquidity pool.

The transaction process in ZKSwap is essentially the process of updating the state tree. The following section will be the introduction of all transaction types in ZKSwap and their corresponding State changes.

## 16. What is the development plan of ZKSwap？

ZKSwap will actively cooperate with exchanges and crypto wallet service providers to support ZKSwap's Layer 2 standard, support ETH and all ERC20 free transfers (including stable coins, etc.), and support private transactions and private crypto swap.

ZKSwap is expected to complete the Plonk zero-knowledge proof system circuit optimization and the introduction of GPU acceleration by the end of 2021. In addition, the L2 Lab that supports the development of ZKSwap will continue to promote the development of the Layer 2 protocol layer. ZKSwap will further explore the application of Layer 2 in NFT, stablecoin, and other fields, and introduce the EVM mechanism to build a standard Layer 2 protocol to support more DeFi projects use ZKSwap technology to build future DeFi applications on Layer 2 and create an open and complete Layer 2 DeFi ecosystem.

L2 Lab will also be committed to promoting the paradigm shift of the blockchain industry. By creating a Layer 2 protocol standard with an excellent user experience, Layer 1 will become the foundation of clearing and settlement, and Layer 2 will become the bridge connecting blockchain applications and Layer 3. And entrances and exits. The mission of ZKSwap is to allow all blockchain applications to run in a layer 3 world without any restrictions.

[ZKSwap Sets Out Roadmap for 2021](https://zkswapofficial.medium.com/zkswap-sets-out-roadmap-for-2021-1fb39be999b3)


# Technology

### 1.ZKSpeed

ZKSwap's first version of the scaling solution (ZKSpeed) combines the features of ZK-rollup, Validium, and Plasma solutions. In addition to this, three optimization improvements including aggregation proof, GPU optimization, and proof circuit optimization are applied to further improve the throughput of the entire network. For details, see the following:

[ZKSwap Introduces Practical ZK-Rollups — ZKSpeed, Achieving High TPS and Low Gas Fees in Real Layer2 DeFi Use Cases](https://medium.com/zkswap/zkswap-introduces-practical-zk-rollups-zkspeed-achieving-high-tps-and-low-gas-fees-in-real-6effe4e789e0)

### 2.ZKSwap Design Specification

Thanks to ZKSync who provides the ZK-Rollup framework for ERC20 token L2 transactions. ZKSwap is a Layer-2 token transaction protocol that uses ZK-Rollups on Ethereum and is based on the PLONK proof system. The ZKSwap design specification explicates the ZKSwap protocol and its difference against ZKSync.

[ZKSwap Design Specification](https://medium.com/zkswap/zkswap-design-specification-ca5ccb32791e)

### 3.Validator

ZKSwap validator is currently run by L2labs Foundation. Many high-frequency AMD CPU servers have been deployed to generate zero-knowledge proofs (ZK-Snarks). In fact, it doesn’t matter who generates or provides the ZK-Snarks, as long as the ZK-Snarks are submitted to the layer-1 network in time.

\
&#x20;ZKSwap team is committed to developing **ZKSwap** into a fully decentralized protocol.&#x20;

We intend to achieve it by introducing an independent consensus mechanism and Proof-of-ZKSnarks mining to encourage users to contribute their computing power to securing the network.&#x20;


# Tutorials

**Bitkeep Wallet Tutorial**

1. Log in into wallet and click “DApp”

![1.Click DApp](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-MjY2viO475_Sww4bEvC%2F-MjYH-Zt9yNXr2gGbeCZ%2Fimage%20\(3\).png?alt=media\&token=0ce95114-e7ed-4ae9-af33-e3060081a624)

&#x20;          2.Input "<https://zks.app>" in the searching window&#x20;

![2.Input "zks.app"](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-MjY2viO475_Sww4bEvC%2F-MjYH8TPrKjg_zF_ccsP%2Fimage%20\(4\).png?alt=media\&token=3e7b5adb-74a4-41f6-9acb-0cdf61279c2e)


# ZKSwap V2 Tutorials

## ZKSwap V2 Introduces:

* **Unlimited Token Listing**
* **Fast withdrawal** (within 20 - 30 mins through optimized circuits)
* **Personalized Fee Token** (Select your preferred token for fee payment)
* **L2 deployment BSC, HECO, OKEX Chain to follow shortly after the V2 mainnet launch.**

## **Migrate Your Assets From ZKSwap V1 to V2**

1.1 Log into [https://v1.zks.app](https://v1.zks.app/), connect to the Ethereum wallet, and withdraw your assets from L2 to L1. (V1 and V2 have independent liquidity. If you add liquidity to V1, remove the liquidity from the L2 Pool before you withdraw your assets.)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fzkswap-en%2F-MflI95SRm65ZvrYP1Ai%2F-MflIVsQN-1Qj_Y5UHRF%2F0.png?generation=1627546062883671\&alt=media)

1.2 You will receive your assets in about 40 minutes depending on how congested the Ethereum network is. (It usually takes 1-3 minutes to send the transaction to L1.)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fzkswap-en%2F-MflI95SRm65ZvrYP1Ai%2F-MflIVsRxVQCp4VuHKhf%2F1.png?generation=1627546062883826\&alt=media)

1.3 Log into the WEB APP of ZKSwap V2 ([https://zks.app](https://zks.app/)), connect to the ETH mainnet wallet, tap L2 Wallet and select Deposit. (The deposit procedure remains the same as V1.)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fzkswap-en%2F-MflI95SRm65ZvrYP1Ai%2F-MflIVsSKedRDR_LTmLb%2F2.png?generation=1627546063062799\&alt=media)

## **List a Token**

ZKSwap V2 supports unlimited token listings. You can list any ERC-20 tokens on ZKSwap V2 now.

Tutorial: <https://en.wiki.zks.org/tutorials/token-token-pair-listing-tutorials>

## **Fee Token Settings**

ZKSwap V2 allows users to select a token among ZKS, WBTC, ETH, and USDT for fee payment. You can edit fee tokens through Settings at the top right corner of the ZKSwap homepage.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fzkswap-en%2F-MflI95SRm65ZvrYP1Ai%2F-MflIVsTQDGc9ZrIZZhY%2F3.png?generation=1627546063065464\&alt=media)

Current use cases for fee tokens: withdrawal, transfer and adding/removing liquidity. (Fees are only applicable when you exceed the daily limit of free transactions.)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fzkswap-en%2F-MflI95SRm65ZvrYP1Ai%2F-MflIVsUfxwSYXGGLlP_%2F4.png?generation=1627546063151427\&alt=media)

In the near future, more fee tokens will be added and applied to more use cases. Stay tuned!


# Token/Token pair listing Tutorials

For V2, users can list any ERC20 tokens after paying gas fees. ZKSwap will charge no fees for the token listing service, which is currently only available on the ZKSwap website. Shortly, ZKSwap will support unlimited tokens and token pairs of all standards on both APP and WEB versions.

PS: This guide is based on the test version and is subject to change.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0GijMh0FUVBl19me6%2F1.png?alt=media\&token=4efb1fdd-11e4-4c94-884f-02316ac22822)

You can also watch the tutorial video  for reference:&#x20;

<https://www.youtube.com/watch?v=0Nw03qp4tg4>

## List Your Token

1. Enter your ERC20 token contract address. Click "Next."\
   Notice: ZKSwap V2 testnet **only supports ERC20 token (released on the ropsten testnet)** listing. Users can check all the token information of the ETH ropsten testnet on <https://ropsten.etherscan.io/>.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0GrsJ3Z6TGvkiU38x%2F2.png?alt=media\&token=984b1fca-258e-4f4b-86dd-3f966592845f)

&#x20;    2.Check out token details. Make sure all is correct and click "Next."

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0H-vpKI-FjRS13UZ5%2F3.png?alt=media\&token=462f93e5-8824-46dc-8f9b-8023d51c3cc6)

## List Your Token Pair

1. Select a Fee Token among ZKS, ETH, and USDT to create a token pair. Click "Submit."

PS: More fee tokens will be made available shortly. Each token pair can only be listed once.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0HN-u7BoEADvx1POb%2F4.png?alt=media\&token=dbba5294-48e0-45c1-a89e-6ec915abc574)

&#x20;    2.Check out token pair details. Make sure all is correct and click "Confirm."

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0HSIz7S5U4arp0qRy%2F5.png?alt=media\&token=365c372d-d1a6-4991-8072-bc6e0d31d3cf)

&#x20;   3.Click "View my listing records" to track the status of your token pair.

It usually takes 5-10 minutes for your token pair to be listed on ZKSwap depending on how congested Ethereum is at the time.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0HXQI8WzTJO8w8IpV%2F6.png?alt=media\&token=1a775d88-5884-4c8e-b010-e6e79200ec70)

&#x20;   4.Congrats! Your token pair has been listed successfully on ZKSwap!

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0HbUItq5Gim-B3S-I%2F7.png?alt=media\&token=81fa312a-451c-41c0-bdc0-8aa3c76a3c55)

## Add More Pairs To Listed Tokens

Click "Trading Pair Listing," enter the token name/contract address or select one from the token list, choose a pair that hasn't been listed on ZKSwap, and click "Submit."

Follow the steps mentioned in the "List Your Token Pair" section.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MV_XFHDOGGH15gLAF_v%2F-Md0FlhLUwMghOLqv0Ch%2F-Md0Hi56xVfqD9wE4y8F%2F8.png?alt=media\&token=588c630e-dada-42e8-8d8f-72ff3d01c883)


# ZKSpace Tutorials

## I. Preface

ZKSpace is an all-featured Ethereum Layer 2 protocol leveraging ZK-Rollups. It includes three products: ZKSwap, ZKSquare, and ZKSea, covering Layer 2 DEX, Layer 2 wallet, and Layer 2 NFT marketplace.You can view the function introduction and technical scheme on the official website of ZKSpace: zks.org.This tutorial gives a comprehensive introduction to how to use the basic functions of each product.

## II. Basic Settings

1. ### Gas Fees and Slippage Settings

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F0qvRWLwtRg6o4EellYyP%2Fimage.png?alt=media\&token=f76d4dcc-3137-4e4b-ae11-10ff2cf1bd6f)

After connecting the wallet, you can click the gear icon on the upper right corner of [https://zks.app](http://zks.app) to set the slippage tolerance and fee token.Slippage refers to the difference between the expected price of a trade and the executed price of that trade that may be caused by other people trading at the same time. You can set your slippage tolerance on the setting card. Once the price fluctuates more than the percentage you set, your submitted transaction will be declined.Fee tokens are the currency set for the entire ZKSpace platform. You can choose among ETH, ZKS, USDT, and WBTC to pay the gas fee required for various operations on the platform.

### 2. Language Settings

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=OTEzMzA0OWJmZTJjNzZkYjU3OWFhYjBlZWZjZmVmNzhfVDdSUGplTU5lbm1EZmRzQ09NY1lDY0RRMVVxZzhGZkdfVG9rZW46Ym94dXNFNjBtQVl1cEhiTnlHMEhsc1FBV3hmXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

You can choose your preferred language in the drop-down list by clicking the language name on the top right corner. We are continually adding more languages options to serve a global user base.

## III. Layer 2 Wallet

Go to [https://zks.app](http://zks.app), the web end app of ZKSpace, and you'll see the Layer 2 wallet in the middle of the page. Since Layer 2 is not a brand-new public chain but a scaling solution for Ethereum, the assets on ZKSpace cannot be displayed in plug-in wallets such as MetaMask. For this reason, we provide the Layer 2 wallet, with which users can view and manage their Layer 2 assets.

### 1. Display of Assets

After connecting your wallet, you can view your assets on ZKSpace. The wallet includes an ERC20 wallet and an NFT wallet, and you can view your ERC20 token assets and your NFT assets separately.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=MDcyMThjYjE2MGQzZjA3MTQ4ODZiZWZhZDAxYTcwZjRfNUtpWDBLSkxEYU5vZVRyRDAwNnF6VDY5cTk5aVVwcG5fVG9rZW46Ym94dXNuNzJ2ZGthM3VwbFkzMWJ1dDFHRjBnXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 2. Deposit, Transfer, and Withdraw

By clicking Deposit, you can deposit your Layer 1 assets to Layer 2. We recommend you use the default Eco Deposit mode, which is designed to save your time and gas fee;By clicking Send, you can send your Layer 2 assets to any other Layer 2 wallet address. You can enjoy an ultra-low transfer gas fee and ultra-fast confirmation experience (i.e., the ZKSquare product);By clicking Withdraw, you can withdraw your Layer 2 assets to the Ethereum mainnet at any time. We recommend you use the default Fast Withdraw to enjoy faster withdrawal confirmation and lower fees.The above three functions apply to both ERC20 tokens and NFTs.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=YTkzYjU0ZGFmYjhkOWJiZGY0NDE4MWU2ZmQ5MjQ3MWRfZXI4R1JtcmttMmNBaW5HTENaTmNtUmNPSFJYajFNMEFfVG9rZW46Ym94dXNoMXNzdmw1ZXdFb3dRWWd3V1Zha0xiXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=ZWVhYTA0YTQ2ZTUwMDE2MGI4ODJlNjQwMWY1YmFkYTRfMUhvTDlTbzFURG90MWRkcVV3M3ZtR0xENmh3R1g3dnFfVG9rZW46Ym94dXMxWmV0d1hTdUh2VEhNUGpQR1FWc0tiXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=ZjJjOWI3OWQzYTc4ZTIzM2NiNjIyNzgwNGM0MDAwMzBfS3R3Rms4Z3VuQUZrTTBYeHA0VnNBVEd1UTU5Z2VQT2pfVG9rZW46Ym94dXNWWDZjdU5TQWVsNnoyeVA4YzZSR1JjXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

## IV. ZKSwap

As a Layer2 DEX launched at first by ZKSpace, we provide users with a decentralized trading service based on the AMM model. You can access this product via L2 Trade on the top of [https://zks.app](http://zks.app).

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=YzkxODJmMzMxNmI4ZmY5ODAxMzEzZjk5MzE2ZGM5MDBfQnVDb1UyYmgzMlJJN3dtREt5V0J3bTIzUENxTGF2RGlfVG9rZW46Ym94dXNyc1JNTkFSeTlCbXBucktOMFZxVXhlXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 1. How to Trade

Click L2 Trade on the top navigation bar on the homepage. Click Swap in the drop-down menu to open the Swap card. Select the trading pair, enter the amount and click Swap to complete your trade.The current market price of the transaction pair, the price impact that your trade might bring, and the gas fee required will be displayed on the card.ZKSwap provides fast trade confirmation and a far-lower gas fee compared to Layer 1 platform Uniswap.Trading on ZKSwap will also enable you to join the Proof-of-Transaction Mining and get ZKS token rewards.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=ZjUwZGYwYWZhZWZmM2JiN2I5NmU3YjE1NzQ1M2IxNzZfZzU1dEJURDdxRVVaSno1UmV1SXRFRE80cjcwM0hGc1hfVG9rZW46Ym94dXM2Z1hqd0V3UVBPVDFMY2lHS3FPSFFnXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 2. How to Make a Market

Click Pool to provide liquidity and earn the liquidity fee provided by traders. You can click the bar that says Add Liquidity, select two currencies, and make a market by adding liquidity according to the current price ratio.By adding liquidity, you can not only earn the liquidity fee, but also participate in Proof-of-Liquidity mining and get ZKS token rewards.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=NTFhNDlmNTZmOTVmNTgwZDQ0MzY3M2U3MDZmNzhiNjNfYjRLTDdnUUNTZlpVU0ROZGxuYkRINTlYbWFHcXpnTDVfVG9rZW46Ym94dXNZZHBwQmJvbVNTMEx3N09peTk4SDRkXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

## V. NFT Market

ZKSpace launched the NFT marketplace ZKSea at the end of 2021 to enable users freely mint and trade NFTs on Layer 2. You can navigate to ZKSea by clicking NFT Market on the top navigation bar of the homepage.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=OGY3NDkyZDYyOGI2YTU1NDVjN2VlOTVmMjAzY2ZmZjZfa0MydUlDRzZCZFBOdVVRSkxRbnE1N1lQTWRNRmowRERfVG9rZW46Ym94dXNLVDI4eTZpZ05KM3lGUU1JSGlkM0tkXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 1. Minting NFT

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=NmM3NTI2NTA4ZDkzN2UxNDc0OTVkMTI1ODBkOGJkMjdfMzRpY28yRnNrVWZmbXJpblFaWnRwdU84bjdRQllzS1FfVG9rZW46Ym94dXN5b3doNk1zVGRzM25UYks2cVJRV3JmXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

Please create your Profile before starting your minting journey. Click the Profile icon on the upper right corner and choose Profile. You can edit your profile photos, username, background, etc. on your Profile page. After this is complete, you can click Mint NFT to start minting.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=NjI5OWM4OTAwNzczZjM1YTZlODEzMTM2YTUyMmMxNjZfR1gwbDJNUWsydndCWHBFYTFFbDVCUVJTeDJncDNuVWpfVG9rZW46Ym94dXNtOEhIWmE4Yks0ZmJsaWNWYktVVlFmXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

The minting process is similar to OpenSea. We support three types of NFT: pictures, videos, and music. Enter the artwork name, upload the work, choose collections for the work, set attributes, and pay the gas fee. After that, you can view the minted NFT in your L2 NFT wallet.NFT minting confirmation is extremely fast on ZKSea, with a gas fee much lower than the Ethereum mainnet.You can also participate in NFT POL mining to get ZKS rewards. Come to ZKSea to mint your own NFT!

### 2. NFT marketplace

#### (1) How to Buy an NFT

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=MTUyMTk0YzY1YmFjMGQ4NDE2ZjMxZDM2OWZjZDQ3YmRfM1UycTVvVnJHWFZnS0FmTzJIaEtqTzdlb2N6WUNma1hfVG9rZW46Ym94dXNIRHNTakVCOVJqV2hTM2hOTnE0S0VoXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

Enter the NFT marketplace, and you can see a dazzling array of NFT works. You can click the heart icon under each NFT to favorite it. You can later go to your Profile page to view your favorite NFTs.For items you want to buy, click Buy and pay the fee, then you get your NFT, which is very fast and convenient.

#### (2) How to Sell an NFT

You can list any NFT in your L2 wallet for sale, whether it is a deposited, purchased, or self-minted NFT.You can click List on the NFT Wallet card of your L2 wallet, or click Sell NFT in the drop-down list of the Profile icon.Set the price you want to sell it for. Your NFT is now listed for sale on ZKSea.There is no charge for listing.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=YzUwZmQwOTY4MDJiZGUwYzRlZGZmMWIwMjM3YTMwMzlfc2U1aEdMSEVwbW5VS0FLOGFCb09MeUhybFFlWTBnMlhfVG9rZW46Ym94dXNmTmpXY3Q5cU9aVDFpM3lTVFZ3eDNmXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

## VI. Mining

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=YTIxMjgzMTMzMDAzYWNhZGI3MDNhZjI1OTU2NmM2ZDFfMVp4THhYMXlVd3hmaTJ1VkF6OGtQaEdrOGZNZVg3Z0tfVG9rZW46Ym94dXNkQ1U5b0YyYWJvUGpCa1FZY3lzbW9jXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

You can enter the mining page by clicking Mining on the top navigation bar of <https://zks.app>. Since 60% of ZKS tokens will be gradually distributed to community users in 4 years, we have currently introduced 7 types of mining activities. They are ZKS Proof-of-Stake mining, Proof-of-Gas mining, Proof-of-Liquidity mining, Proof-of-Transaction mining, NFT Proof-of-Liquidity mining, NFT Proof-of-Transaction mining, and NFT Proof-of-Deposit mining. The rules may be slightly different in different periods. Go to <https://zks.app/mining> for a detailed description.

### 1. ZKS Proof-of-Stake (PoS) Mining:

We open 30 days, 90 days, 180 days, or 360 days of ZKS PoS mining activities regularly. You can participate by withdrawing ZKS tokens to the Layer 1 wallet, and locking it into the corresponding smart contract following the guide. There are different APRs for different lock-up duration. Please refer to the event page for details.<br>

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=ZWM5ZWZhNzY2ZjA1ZDE2YjFlMTcyN2IzZWM3YzM5ZDBfeno1emlldEFJNEx4RTVBdVdTWUJ0cnc4NmhSRHVJV1pfVG9rZW46Ym94dXNpaE1SZEhQeHY0RE1JcTdNRk5HcmxnXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 2. Proof-of-Gas (PoG) Mining:

ZKSpace will aggregate and package all transactions on the platform and synchronize them to the Ethereum mainnet to ensure the same security as Layer 1. A certain amount of ETH will be consumed every day as the mainnet gas fee. Therefore, we reward users who pay the gas fee to the platform with ZKS tokens through PoG mining.You can deposit ETH on the PoG mining page to participate and get ZKS token rewards on a daily basis. The specific APR may vary slightly according to the actual gas consumed by the platform every day. Please refer to the event page for details.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=ZmFkNmZlYTEyMDNmNTI0ZDgwNjM4MDcyYTEzMTFhOTZfa0t6YWdZTTVybFJNVGkxQzhmeENCMGFuWkh0SGE5MTJfVG9rZW46Ym94dXN5czJEMmw0RDh5dktsQVRBNERqcWRoXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 3. Proof-of-Liquidity (PoL) Mining

As mentioned earlier, users who provide liquidity for ZKSwap can not only earn the liquidity fees provided by traders but also participate in PoL mining to earn more ZKS income.You automatically participate in PoL mining by adding liquidity of the corresponding trading pair. No staking is required. You can withdraw your fund at any time, which delivers a high degree of freedom.We will open PoL mining for different trading pairs at different stages. Please note that when the NFT Boost activity is opened, holding NFTs from specific collections can provide additional bonuses for mining. Please pay attention to the official blog announcement for updates and the event page for details.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=NDIxOGQ4ZDU0OTMxMGNhNmU2YzVkZDljNTMzYjJkNGFfVmY1b3J5MFZmNmUxd2YxMnJuaUNzM2RBc0UyYzU3TjFfVG9rZW46Ym94dXN3YTdEUWtQWDRMZ1pHdGc3UXk1dk5oXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 4. Proof-of-Transaction (PoT) Mining

Trading on Layer 2 can not only meet your needs for token swaps but also get you ZKS token rewards based on the amount of transaction fee you have paid.We will open PoT mining for different trading pairs at different stages. Please note that when the NFT Boost activity is opened, holding NFTs from specific collections can provide additional bonus for mining. Please pay attention to the official blog announcement for updates and the event page for details.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=NDg3ZmMzOGJhYmFmMjRmMTBmMWVjMThiMjc5YzBlNDdfTHhzY3B6d3NyY0s0VDFoVU03NldaRWFPRGNRbzkzUVNfVG9rZW46Ym94dXN3MElqdFZxZHlTTjlXOGg5UkxDSjZVXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 5. NFT Proof-of-Liquidity Mining

You can participate in NFT PoL mining after adding liquidity to ZKSea. Minting, listing, or successfully selling NFTs enable you to split the daily ZKS token reward. Please refer to the event page for detailed rules.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=YWNkNzVlMGIwMWJmNjk4ZjFhNmEzYmEzMjU0YzYzN2RfazhsdllyeldsTXV1T3ROZHJwWHJORlFyRmRpbmtPOFVfVG9rZW46Ym94dXNCRndaMGZUYjhHVW5kUmJuc3Zob1ljXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 6. NFT Proof-of-Transaction Mining

You can participate in NFT PoT mining simply by buying an NFT on ZKSea. The reward pool will be shared based on the proportion of your transaction. Please refer to the event page for detailed rules.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=OGE5YmI2OGFmNjg0ODcyNTFhMTFlNGZjNjM1Yzk0ZDVfR2lUYUVjenRsTDA2VzdLVFFUNkVud2lEcWx2aDQ2N3dfVG9rZW46Ym94dXNGWWJnRktxVjlYNXBPUElraFlrT0liXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

### 7. NFT Proof-of-Deposit Mining

To motivate users to bring well-known Layer 1 NFTs to Layer 2 for trading, we have launched the NFT PoD mining to reward users who deposit specific blue-chip NFTs and list them on ZKSea.You will earn 1,000 ZKS by depositing and listing a single NFT. In addition, when the NFT Boost activity is opened, the NFTs you deposited can also provide bonuses for PoT and PoL mining rewards. Please refer to the event page for detailed rules and supported NFT collections.

![](https://k9onu1bzg3.larksuite.com/space/api/box/stream/download/asynccode/?code=OTAwYjJkM2RkMzBkNTg4NTg4NzY2NDFlNTdkNGE1MTdfWThJQWs4SGJ5RFNJb1g2N2JscTVhWEg5ckhNck1IWmRfVG9rZW46Ym94dXNMazNCVTU4YlBTd2VKdnlFYlY4NjJmXzE2NTA0NDA0MjU6MTY1MDQ0NDAyNV9WNA)

## Ⅶ. ZKSpace Rate system

Based on the ZKSpace business development plan and the upcoming "ZKS Economic White Paper V2.0", we will adopt a brand-new rate system.

### 1. **Cancel App usage restrictions**

The original restriction on the minimum deposit of 50 ZKS or 200 USDT for the APP usage has been canceled. You can now deposit any amount of assets to Layer-2.

### 2. **Cancel free Layer-2 operations**

As the PoG mining is about to cease, we will no longer provide full subsidies for Layer-2 operations, and Gas fees for on-chain operations will be paid by yourself.

### 3. Gas fee system

#### （1）ZKSwap

Add liquidity: 1 USDT&#x20;

Remove liquidity: 1 USDT&#x20;

Swap: 0.5 USDT

#### （2）ZKSquare

Deposit: 0 USDT (Free)&#x20;

Layer-2 transfers: 0.2 USDT&#x20;

Withdrawals to Layer-1: 3 USDT

#### （3）ZKSea

Mint an NFT: 2 USDT&#x20;

List an NFT: 0 USDT (Free)&#x20;

Unlist an NFT: 1 USDT&#x20;

Buy an NFT: 5 USDT&#x20;

Transfer an NFT: 0.5 USDT&#x20;

Withdraw an NFT to Layer-1: 30 USDT if the NFT has been deposited from Layer-1; 120 USDT if the NFT has been minted on Layer-2.


# ZKSea Tutorials

## **1.Preface**

After the brand upgrade, we launched the Layer-2 full-featured protocol ZKSpace, which includes all the functions of the ZKSwap V2 version, and added ZKSea products to support all the NFT functions of Layer-2.

This tutorial will not repeat the basic functions of the ZKSwap V2 product, but mainly introduces the changes in the new version and the steps to use ZKSea.

## 2.ZKSea

### a. Preliminary preparation

Log in to the ZKSpace WEB APP: zkspace.app.

ZKSea is a Layer-2 NFT product based on ZKSpace. You can only use the funds in the Layer-2 wallet for NFT trading. Make sure you have a certain amount of funds in your Ethereum Layer-2 wallet.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FUKt7wM1lHoMXDtJAHkwo%2F0?alt=media)

Please refer to the "[ZKSwap V2 Tutorials](/tutorials/zkswap-v2-tutorials)" for the procedures of wallet connection and asset deposit/withdrawal.

### b. NFT wallet

You can enter the NFT mall through the NFT Market button on the navigation bar, which provides NFT purchase, minting, and other services. Details of your Layer-2 NFT record can be found in your NFT Wallet.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FyWDx7TfRHIqchNVQ4fta%2F123.jpeg?alt=media\&token=9ebfa0f8-0e66-4945-994a-ce9909e799ef)

The above image shows what the NFT Wallet would be like. All NFTs owned by you will be displayed in your NFT Wallet. The deposit, transfer, and withdrawal of NFTs are the same as ERC-20 tokens.

### c.NFT Mall

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2Fn7VU6RrMPqPEgUUWU6sK%2F2?alt=media)

In the NFT Market, parts of the ZKSpace functions on the navigation bar are hidden to fully display the NFT-centered options.

Discover your favorite NFTs in the NFT Market. Remember to check out the details of an NFT before making a payment.

### d. User Page

Before minting an NFT, you need to enter the User Page in the upper right corner to complete the author information, including the avatar, nickname, personal introduction, etc.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FX5iLUcFGVbEdZ5oQ1m7U%2F3?alt=media)

### e. Mint NFT

Click the Mint NFT button on the navigation bar, fill in the basic information of your NFT, upload your work, and pay the required gas fee to complete the NFT minting.

It is worth mentioning that ZKSea is a decentralized NFT platform, and anyone can create their favorite NFTs on the platform.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FBEKs5tNzCI4uFWpSIeQb%2F4?alt=media)

### f.Sell NFT

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FkxJbNRRS1CJNqkszSeEu%2F5?alt=media)

Enter the User Page, select the NFT you want to sell, click the List button, and enter a price to sell it in the NFT Market.

Note: You can also find the List button by clicking on your NFT and entering the details page.


# Banxa-ZKSpace Tutorial

Connect your wallet on [ZKSpace](https://zks.app/wallet/token/deposit/fiat) with the below options.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FbLix12LbwiQGsK4njzCV%2F0?alt=media)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FGUN9RZ4xpWmDjJesHGvY%2F1?alt=media)

Click on "Buy Crypto", and a pop-up will take you to the next step.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F0uLia1aMGnRIpxsOVFE0%2F2?alt=media)

**OR** click on "L2 Wallet" and select "ERC20 Wallet" to proceed.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FGFGR7rl8itM6gABLJE1y%2F3?alt=media)

You will be taken to Banxa’s site to review your order and pick your payment method. Select Currency ( (USD, AUD, EUR, CAD, etc.) you want to pay with and input the amount. Then click "Create Order".

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FUctlyXzeAftX9UMFqMG9%2F4?alt=media)

Enter your contact details, including your email address and phone number.

***Note:** Please double-check if you entered both correctly as Banxa will get in touch with you regarding your order via email or SMS.*

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FKkV7ckH302ca9cUmfBw4%2F5?alt=media)

You will receive a text message with a verification code. Enter the verification code correctly to proceed.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2Fg4D9lWcQhX84l58qc2Os%2F6?alt=media)

Enter personal details correctly.

***Note:** Please make sure details are exactly how they are shown on your official ID.*

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FjnrolWd7DbQlUya4NwkM%2F7?alt=media)

Select your country and upload your ID as well as a selfie of you holding your ID.

***Note:** Please read and follow the instructions as indicated on the website carefully. Your document needs to be valid and current. Also, please ensure that when you take a photo of your document, all important details are visible and not obscured in any way. For more information on how to pass verification, please click* [*here*](https://support.banxa.com/en/support/solutions/articles/44002190039-how-do-i-pass-verification-)*.*

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F4vOoJZbXZP94UA1YXwhI%2F8?alt=media)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FLuLpTKd3earoCaF3LpIe%2F9?alt=media)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FJS30R2kXldoYWLEUmlsb%2F10?alt=media)

***Note:** The selfie photo needs to be clear, not blurry, and without any glare. Your face must be clear, and the information on the document you are holding has to be readable. The photo must be taken on the day of your order.*

Select your main purpose of trading Crypto. Please confirm before continuing.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FWhlmbpBnzZah9NqHx2Qj%2F11?alt=media)

Input your card information.

***Note:** According to Banxa, for Visa/ Mastercard- the card needs to be your personal (not business) card and has to be in your name; for SEPA Bank Transfer and iDEAL – the bank account has to be in your name (i.e. the name of the person creating the order has to be the same as the name on the bank account).*

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F3RZnBi541eh1mZ67ylCw%2F12?alt=media)

You have placed the order and will receive updates on the order status and action required via email from Banxa.

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2Fu3axWUSLIjMgDavcLCzT%2F13?alt=media)

You will get notification emails from Banxa, including links to check your transaction status on the blockchain network, how your order is progressing, etc. When your order is fulfilled, i.e. the transfer completed and the transaction verified on the blockchain network, your coins will be visible in your account/wallet.

***Note:** For more information regarding the* processing *time, please click* [*here*](https://support.banxa.com/en/support/solutions/articles/44002216503-how-long-will-my-order-take-)*.*

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FVMMBfCiIB8ra9pmridx7%2F14?alt=media)

![](https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2Fpjn6qwfsnygP7vnUvuf1%2F15?alt=media)


# Step to Step Tutorial of Using ZKSwap (Bitcoin) Testnet Version

### Step 1: Claim testnet BTC tokens:

* Using Taproot Address: Visit these faucets, input your address to claim testnet BTC.
  1. <https://cryptopump.info/send.php>
  2. <https://bitcoinfaucet.uo1.net/send.php>
  3. <https://kuttler.eu/en/bitcoin/btc/faucet/>
* Using Native Sigwit address: Visit "<https://coinfaucet.eu/en/btc-testnet/>", input your address to claim testnet BTC, and then **transfer to your Taproot address.**

### Step2: Log in

Link a Taproot format BTC testnet address in ZKSwap.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FmloPQg1qWlw0i6MwlBNg%2F1.png?alt=media&amp;token=0f6af03c-7b1a-43b7-852b-bd04403bd2a5" alt=""><figcaption></figcaption></figure>

### Step3: Deposit to ZKSwap

1. On the Asset page, click "Deposit" to enter the deposit page.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FfdCK1IMjmPtyxIwQDQZD%2F2.png?alt=media&amp;token=2868ecb7-f059-4c21-942d-a76f78f4eebe" alt=""><figcaption></figcaption></figure>

2. From the dropdown menu, select the type of currency to deposit.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FSEKJKN3OzaRBa7OqmRKx%2F3.png?alt=media&amp;token=fedbc750-5dc3-4d02-a681-554fefb17fef" alt="" width="375"><figcaption></figcaption></figure>

3. If depositing BTC:

   (1) Enter an amount less than what is available in the wallet.

   (2) Click the "Deposit" button to prompt the wallet to sign the transaction; the deposit is successful after three block confirmations.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FbBIbVYBBVzwO6Oh4vKhZ%2F4.png?alt=media&amp;token=4316bca6-6051-4eb0-9219-b8f4885ad3a0" alt="" width="375"><figcaption></figcaption></figure>

4. If depositing BRC-20 tokens:\
   (1) Perform an "Inscribe transfer" for the amount you wish to deposit.

<div align="left"><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FSkrSNxqB4MpgSgSZpXBA%2F5.png?alt=media&amp;token=b7bd12e7-f991-412d-83ce-677cbff53bea" alt="" width="375"><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F2F8Mujsdg1BLialPeY5H%2F6.png?alt=media&amp;token=d7d722cf-906b-4fac-a84e-b3fc2f7a663e" alt="" width="375"><figcaption></figcaption></figure></div>

&#x20;  (2) Select a transfer inscription.

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FRlctnWsbLmDk9YO2n3py%2F7.png?alt=media&amp;token=3599ee6f-2808-42a5-b0b3-d39f21f203cf" alt="" width="375"><figcaption></figcaption></figure>

&#x20;  (3) Click the "Deposit" button to prompt the wallet to sign the transaction; the deposit is successful after three block confirmations.<br>

### Step4: Swap

1. Go to the "Swap" on the navigation bar

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FFE0y5JFDJbQC5oZKR2T2%2F8.png?alt=media&amp;token=92c39908-0f8c-4931-89c5-94d2dab02e29" alt=""><figcaption></figcaption></figure>

2. Choose your currency pairs

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FcZcccXKj6yLk4kgi6pNS%2F9.png?alt=media&amp;token=8210219b-c571-489a-85be-51d2a6dfb8a6" alt="" width="375"><figcaption></figcaption></figure>

3. Enter the amount for the transaction

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FKhRO5OtLRpE10KjTepZQ%2F10.png?alt=media&amp;token=fd62216a-3438-466b-859d-986e7ded01ae" alt="" width="375"><figcaption></figcaption></figure>

4. Click "Swap" to confirm and complete the transaction in your wallet

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F7IkWJgd3JiZxsWcWixg3%2F11.png?alt=media&amp;token=3bd51287-cdad-4106-a4ff-9aea9395d683" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FKnkuBrvn6e6xq3p67gsm%2F12.png?alt=media&amp;token=e615213c-0579-48e3-aa44-723392773d03" alt=""><figcaption></figcaption></figure></div>

### Step5: Add Liquidity

1. Go to the "Pool" in the navigation bar

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FSJVtjbeIRlurGTVMnt0w%2F13.png?alt=media&amp;token=e6e4c71a-76a3-4e2f-bc4c-b265904d3c4d" alt=""><figcaption></figcaption></figure>

2. Click on "Add Liquidity" on the Pool page

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FeMiZNlSyLy2AMOJaYuTm%2F14.png?alt=media&amp;token=502c523a-8d8b-4729-8969-7d048e59d45c" alt="" width="375"><figcaption></figcaption></figure>

3. Choose the two assets you want to add liquidity for

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FGxM7O52MEGDiswMaBaw6%2F15.png?alt=media&amp;token=606110d6-56c1-47a1-ac99-60a4e333cbdc" alt="" width="375"><figcaption></figcaption></figure>

4. Enter the amount of tokens you wish to add

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FGxM7O52MEGDiswMaBaw6%2F15.png?alt=media&amp;token=606110d6-56c1-47a1-ac99-60a4e333cbdc" alt="" width="375"><figcaption></figcaption></figure>

* If the trading pair doesn't exist, enter the quantities for both tokens separately
* If the trading pair exists, input the quantity for one token, and the quantity for the other will be auto-filled

5.Click "Apply Liquidity" to confirm and add liquidity to your wallet

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F2DIySfxYre9U2eSrFTl2%2F16.png?alt=media&amp;token=1040baf3-4ed1-482d-91e0-bdb7ebc39f35" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FuM9bKQ97lKFk7XT00nUl%2F18.png?alt=media&amp;token=e7b06f85-cef7-4c78-b9fc-b840b23daa4a" alt=""><figcaption></figcaption></figure></div>

### Step6: Manage Liquidity

1. Go to the "Pool" in the navigation bar and view the liquidity added by your account at "My Pool" section

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F1ePqeWDEKgb9BituOrmR%2F19.png?alt=media&amp;token=f569b769-5c57-40ef-94a9-06d34dc9dc73" alt=""><figcaption></figcaption></figure>

2. Click the "+" button to add liquidity for a trading pair, similar to the process for adding liquidity

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FaPBJTeGxBX32EcSnsU5f%2F20.png?alt=media&amp;token=1cc1bb21-1dbc-4758-b7ca-df805cbb7aa9" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FQAkmxRWrl7417oK8JK8w%2F21.png?alt=media&amp;token=547070aa-fa0c-455a-b5d3-b5aff397ee73" alt=""><figcaption></figcaption></figure></div>

3. Click the "-" button to remove liquidity, adjust the slider or input the amount to be removed

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F8VElkByWXkBf0rfVeD3N%2F22.png?alt=media&amp;token=8af65210-3177-49d9-a756-e611a2d2ce76" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FGZaeeOCGkkwzgOoZMAzO%2F23.png?alt=media&amp;token=f6e60951-a9ee-4376-8e9c-eba11ee88699" alt=""><figcaption></figcaption></figure></div>

4. Click "Add Liquidity" or "Remove Liquidity" to confirm and remove liquidity in your wallet after signing and confirming the transaction

### Step7: Withdraw to Bitcoin Testnet

1. Go to the "Asset" and click on "Withdraw" to access the withdrawal page

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FNPoPmFp6k5t0w9GIBmxn%2F24.png?alt=media&amp;token=659dba5d-1a79-46c8-8d07-a58ba85d11b3" alt=""><figcaption></figcaption></figure>

2. Select the currency you wish to withdraw

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FU6Po7oyF2WKAbPkxiUMG%2F25.png?alt=media&amp;token=9494bcbd-5d98-4600-b65b-8aa9191b023c" alt=""><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2Fa8BCRVeIfjApgBgk7JBl%2F26.png?alt=media&amp;token=fae21dc6-d624-4290-b631-a12a77707964" alt=""><figcaption></figcaption></figure></div>

3. Enter the amount you want to withdraw

<figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2Fhg44eV1noVEbzHx3ekre%2F27.png?alt=media&amp;token=e57b70ee-c114-444f-b56a-b682ae1df2c2" alt="" width="375"><figcaption></figcaption></figure>

4. Click the "Withdraw" button to confirm and complete the transaction in your wallet

<div><figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2FkrQ9NW8thsp96HwlNJSB%2F28.png?alt=media&amp;token=a8020d32-2fae-4514-9f16-022d9387252a" alt=""><figcaption></figcaption></figure> <figure><img src="https://3124259879-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MV_XFHDOGGH15gLAF_v%2Fuploads%2F36jrKlN8ldQFf3shrIhj%2F29.png?alt=media&amp;token=d1b0ccdd-132b-44a2-a704-a3178c6b0cf6" alt=""><figcaption></figcaption></figure></div>


# Interact with ZKSwap

{% content-ref url="/pages/-MgtM7E8oyrISWOI39CW" %}
[RESTful API](/interact-with-zkswap/restful-api)
{% endcontent-ref %}

{% content-ref url="/pages/-MgtUXJJJqaxByQwmDbr" %}
[Make Transaction](/interact-with-zkswap/make-transaction)
{% endcontent-ref %}


# Definition

Here're some constants which may be used in the following APIs.

### Versions

* `v3`: the latest version of ZKSpace
* `v2`: the previous version of ZKSwap

### Networks (layer-1 chain ID)

* `1`: Ethereum mainnet
* `4`: Rinkeby testnet

### Chain IDs (layer-2 chain ID)

* 13: Ethereum mainnet for v3
* 11: Ethereum mainnet for v2
* 133: Rinkeby testnet for v3


# RESTful API

## Get Contract Address

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/contract-address`

Returns the contracts being used for deposit, etc. In most time, the response won't be changed.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": {
        "gov": "0x86E527BC3C43E6Ba3eFf3A8CAd54A7Ed09cD8E8B",
        "main": "0x6dE5bDC580f55Bc9dAcaFCB67b91674040A247e3"
    }
}
```

{% endtab %}
{% endtabs %}

## Get Token List

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/tokens`

Returns all tokens which have been listed on ZKSwap.

#### Query Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": [
        {
            "id": 0,
            "address": "0x0000000000000000000000000000000000000000",
            "decimals": 18,
            "symbol": "ETH",
            "icon": "https://s.zks.app/icons/v2/0x0000000000000000000000000000000000000000.png",
            "approved": true
        },
        {
            "id": 10,
            "address": "0xe4815ae53b124e7263f08dcdbbb757d41ed658c6",
            "decimals": 18,
            "symbol": "ZKS",
            "icon": "https://s.zks.app/icons/v2/0xe4815ae53b124e7263f08dcdbbb757d41ed658c6.png",
            "approved": true
        },
        {
            "id": 32,
            "address": "0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9",
            "decimals": 18,
            "symbol": "AAVE",
            "icon": "https://s.zks.app/icons/v2/0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.png",
            "approved": true
        }
    ]
}
```

{% endtab %}
{% endtabs %}

Here's the schema of each token:

| Field    | Type    | Comment                                                               |
| -------- | ------- | --------------------------------------------------------------------- |
| id       | number  | The unique ID starting from 0, which is native coin.                  |
| address  | address | Native coin's address is `0x0000000000000000000000000000000000000000` |
| decimals | number  | The number of decimals used to get its user representation.           |
| symbol   | string  | The unique symbol indicates the symbol.                               |
| icon     | string  | The image url shows the icon.                                         |

## Get Token Prices

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/tokens/price`

Returns all tokens' prices on ZKSwap.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": [
        {
            "id": 0,
            "price": "2968.1483043140707263"
        },
        {
            "id": 10,
            "price": "0.7862725980605806"
        },
        {
            "id": 32,
            "price": "0"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

| Field | Type   | Comment          |
| ----- | ------ | ---------------- |
| id    | number | The unique ID.   |
| price | string | The unit is USD. |

## Get Pair List

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/pairs`

Returns all pairs which have been added on ZKSwap.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": [
        {
            "id": 16384,
            "address": "0xda097aa54e44e389f2acadb69027c8780a8ec852",
            "decimals": 18,
            "symbol": "liquidity_10_32",
            "id_a": 10,
            "id_b": 32,
            "anchored": 10
        },
        {
            "id": 16385,
            "address": "0x9c883156e724ceb48d230da0132fab4aa721ae84",
            "decimals": 18,
            "symbol": "liquidity_8_10",
            "id_a": 8,
            "id_b": 10,
            "anchored": 8
        },
        {
            "id": 16386,
            "address": "0xaa45c964e21eafb38574e9d000adbaf85acfbb80",
            "decimals": 18,
            "symbol": "liquidity_0_10",
            "id_a": 0,
            "id_b": 10,
            "anchored": 0
        }
    ]
}
```

{% endtab %}
{% endtabs %}

| Field    | Type    | Comment                                                                     |
| -------- | ------- | --------------------------------------------------------------------------- |
| id       | number  | The unique ID starting from 16384.                                          |
| address  | address | It's the same as the LP token on Layer-1.                                   |
| decimals | number  | The number of decimals used to get its user representation, it's always 18. |
| symbol   | string  | The unique symbol follows the format `liquidity_{idA}_{idB}`.               |
| id\_a    | string  | The ID of token A.                                                          |
| id\_b    | string  | The ID of token B.                                                          |

## Get Pair Prices

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/pairs/price`

Returns all pairs' prices on ZKSwap.

#### Path Parameters

| Name    | Type   | Description                                             |
| ------- | ------ | ------------------------------------------------------- |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc.网 |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": [
        {
            "id": 16384,
            "amount_a": "0",
            "amount_b": "0",
            "price": "0",
            "totalSupply": "0"
        },
        {
            "id": 16385,
            "amount_a": "1464474.697055",
            "amount_b": "1859053.645591589842522106",
            "price": "1782999.9600978410438763",
            "totalSupply": "1.642708614502310855"
        },
        {
            "id": 16386,
            "amount_a": "33.667299246695146243",
            "amount_b": "127772.687849889681268329",
            "price": "96.778364123199939",
            "totalSupply": "2065.121436478357148901"
        }
    ]
}
```

{% endtab %}
{% endtabs %}

| Field       | Type   | Comment                                                               |
| ----------- | ------ | --------------------------------------------------------------------- |
| id          | number | The unique ID.                                                        |
| amount\_a   | string | The formatted amount of token A in the pair (also known as reverse0). |
| amount\_b   | string | The formatted amount of token B in the pair (also known as reverse1). |
| price       | string | The number indicates how much 1 LP token values.                      |
| totalSupply | string |                                                                       |

## Get Account Balance

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/account/:address/balances`

Returns the balances of an address. If the address never had a token/pair, it won't be listed. All the unit of asset is USD.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |
| address | string | The account's address, which is case insensitive.      |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": {
        "balances": {
            "tokens": [
                {
                    "id": 8,
                    "amount": "14.918202",
                    "Value": "0"
                },
                {
                    "id": 10,
                    "amount": "720651.4115822",
                    "Value": "0"
                },
                {
                    "id": 32,
                    "amount": "0.6027962441",
                    "Value": "0"
                }
            ],
            "pairs": [
                {
                    "id": 16385,
                    "amount": "0.000294957624075052",
                    "Value": "523.4426987137814436216811147071194148"
                },
                {
                    "id": 16387,
                    "amount": "0.000004427188724235",
                    "Value": "482.09321566002294012027060109989963"
                }
            ]
        },
        "asset": {
            "tokens": "562353.0359099654094174914699",
            "pairs": "1005.5359143738043837419517158070190448",
            "total": "563358.5718243392138012334216158070190448"
        }
    }
}
```

{% endtab %}
{% endtabs %}

## Get Account Info

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/account/:address/info`

Returns the id, nonce and pubKeyHash of the account. If the address never had any asset on ZKSwap, the id is 0.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |
| address | string | The account's address, which is case insensitive.      |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": {
        "id": 2,
        "nonce": 1256,
        "pub_key_hash": "sync:e4762290aa804636fd63ee25fe91497a8ea01dea"
    }
}
```

{% endtab %}
{% endtabs %}

## Get Account Fee

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/account/:address/fee`

&#x20;All fees are in USD.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |
| address | string | The account's address, which is case insensitive.      |

{% tabs %}
{% tab title="200 " %}

```
{
    "success": true,
    "data": {
        "transfer": "0",
        "withdraw": "5",
        "add_liquidity": "0",
        "remove_liquidity": "0"
    }
}
```

{% endtab %}
{% endtabs %}

## Get Transaction List

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/txs`

Returns the list of transactions.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |

#### Query Parameters

| Name    | Type   | Description                                                                                         |
| ------- | ------ | --------------------------------------------------------------------------------------------------- |
| address | string | The transaction address. No matter it's sender or receiver.                                         |
| types   | string | The list of types, seperated with \|. See below for all types. e.g. `AddLiquidity\|RemoveLiquidity` |
| token   | number | The unique ID of a token                                                                            |
| start   | number | Default 0.                                                                                          |
| limit   | number | Default 50. Maximum 50.                                                                             |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": {
        "pagination": {
            "total": 2,
            "start": 0,
            "limit": 100
        },
        "data": [
            {
                "amount": "2",
                "block_number": 1920,
                "created_at": 1628344581,
                "fail_reason": "",
                "fee": "0",
                "fee_token": 0,
                "fee_value": "0",
                "from": "0x961b513dfd3e363c238e0f98219ee02552a847bd",
                "id": 6014,
                "nonce": 1252,
                "status": "verified",
                "success": true,
                "to": "0x1c65291ba1c67b539d6f957fcc2f1944c146dbc9",
                "token": {
                    "id": 10,
                    "symbol": "ZKS"
                },
                "tx_hash": "0x3dca53000392ff1fc059f40b0a64a247d94bd7d46ec05397da13aaf592cb902e",
                "tx_type": "Transfer",
                "value": "1.72841"
            },
            {
                "amount": {
                    "amount": "0.000004427188724235",
                    "amount_a": "0.1",
                    "amount_b": "196"
                },
                "block_number": 14,
                "created_at": 1626329003,
                "fail_reason": "",
                "fee": "0",
                "fee_token": 8,
                "fee_value": "0",
                "from": "0x961b513dfd3e363c238e0f98219ee02552a847bd",
                "id": 19,
                "nonce": 2,
                "status": "verified",
                "success": true,
                "to": "0x2e35bb0d1570b1fb816255974a21b375cefe1eca",
                "token": {
                    "id": 16387,
                    "id_a": 0,
                    "id_b": 8,
                    "symbol_a": "ETH",
                    "symbol_b": "USDT"
                },
                "tx_hash": "0x42453836dbe9689a75be663534a5c3de73901c38c56defb406b9135a510625b2",
                "tx_type": "AddLiquidity",
                "value": "392"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

Each transaction contains the following fields:

| Field         | Type    | Comment                                                                                                                                 |
| ------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| tx\_hash      | string  | The hash of the transaction.                                                                                                            |
| tx\_type      | string  | One of the following: `Deposit`, `Transfer`, `Withdraw`, `Swap`, `AddLiquidity` and `RemoveLiquidity`.                                  |
| status        | string  | `pending` or `verified`                                                                                                                 |
| from          | address | The transaction sender.                                                                                                                 |
| to            | address | The transaction receiver. For `Swap`, `AddLiquidity` and `RemoveLiquidity`, the receiver is the pair address.                           |
| token         | object  | It always contains `id`. For `Swap`, `AddLiquidity` and `RemoveLiquidity`, it contains `id_a` and `id_b`.                               |
| amount        | mixed   | For `Deposit`, `Withdraw` and `Transfer`, it's the formatted amount. For other type, it's an object contains `amount_a` and `amount_b`. |
| value         | string  | The value of transaction in USD.                                                                                                        |
| fee\_token    | number  | The ID of transaction fee token.                                                                                                        |
| fee           | string  | The transaction fee.                                                                                                                    |
| fee\_value    | string  | The value of transaction fee in USD.                                                                                                    |
| block\_number | number  | The block it belongs.                                                                                                                   |
| created\_at   | number  | The UNIX timestamp when the transaction created.                                                                                        |
| success       | boolean | Indicates the transaction is successful or not.                                                                                         |
| fail\_reason  | string  | Only contains message when transaction failed.                                                                                          |
| nonce         | number  | Similar with ETH's nonce.                                                                                                               |

## Get Transaction

<mark style="color:blue;">`GET`</mark> `https://api.zks.app/:version/:network/tx/:tx_hash`

Return the transaction data.

#### Path Parameters

| Name     | Type   | Description                                            |
| -------- | ------ | ------------------------------------------------------ |
| network  | number | The network number. 1 for mainnet, 3 for ropsten, etc. |
| tx\_hash | string | The transaction hash.                                  |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": {
        "id": 586433,
        "tx_hash": "0x9073df41def307564a8cd569cbae0c2a813b4c3d5f692e1a3a8323b7fab42d2d",
        "tx_type": "AddLiquidity",
        "status": "verified",
        "from": "0xd6e1e53465f50d4b1a8294b052e5f972fba5ebe4",
        "to": "0x5c7d7683758b449c11fcbd68da4e9a5398073f35",
        "token": {
            "id": 213,
            "id_a": 30,
            "id_b": 29,
            "symbol_a": "BUSD",
            "symbol_b": "USDT"
        },
        "amount": {
            "amount": "0.000261185806411614",
            "amount_a": "261.08086447",
            "amount_b": "261.495942"
        },
        "value": "522.99188",
        "fee": "0",
        "fee_value": "0",
        "fee_b": "0",
        "fee_b_value": "0",
        "block_number": 41440,
        "created_at": 1617298650,
        "success": true,
        "fail_reason": "",
        "nonce": 10
    }
}
```

{% endtab %}
{% endtabs %}

## Submit Transaction

<mark style="color:green;">`POST`</mark> `https://api.zks.app/:network/tx`

Submit the transaction to ZKSwap Layer-2. Returns the transaction hash if it's accepted.

#### Path Parameters

| Name    | Type   | Description                                            |
| ------- | ------ | ------------------------------------------------------ |
| network | number | The network number. 1 for mainnet, 3 for ropsten, etc. |

#### Request Body

| Name           | Type    | Description                                            |
| -------------- | ------- | ------------------------------------------------------ |
| tx             | object  | The signed transaction data.                           |
| signature      | object  | Layer1 signature. For ChangePubKey, it should be null. |
| fastProcessing | boolean | null                                                   |

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "success": true,
    "data": "sync-tx:26fc8afdd61d944489e2139aea900bbd34fc71eaad9a741e7e66320b46993f4d"
}
```

{% endtab %}
{% endtabs %}

Click [here](https://app.gitbook.com/@zkswap-1/s/zkswap-en/interact-with-zkswap/make-transaction) to see how to make a transaction.


# Make Transaction

In the following article, we will use this wallet as example:

```javascript
Address: 0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF
Private Key: 0x1c1a49fea9a4ede1dc8e582639f498d41fa3c4a9e2ab2b9d740a4a3ec14e1cbf
```

## Layer-1

The only transaction that made on Layer-1 is deposit. It has two sub-types which are `DepositETH` and `DepositERC20`.

### ABIs

```javascript
[
  {
    "constant": false,
    "inputs": [
      {
        "internalType": "contract IERC20",
        "name": "_token",
        "type": "address"
      },
      {
        "internalType": "uint104",
        "name": "_amount",
        "type": "uint104"
      },
      {
        "internalType": "address",
        "name": "_franklinAddr",
        "type": "address"
      }
    ],
    "name": "depositERC20",
    "outputs": [],
    "payable": false,
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "constant": false,
    "inputs": [
      {
        "internalType": "address",
        "name": "_franklinAddr",
        "type": "address"
      }
    ],
    "name": "depositETH",
    "outputs": [],
    "payable": true,
    "stateMutability": "payable",
    "type": "function"
  }
]
```

### Deposit ETH

Example Code:

```javascript
import { Wallet, Contract, utils } from 'ethers'

const contract = new Contract('0x8ECa806Aecc86CE90Da803b080Ca4E3A9b8097ad', ABI, wallet)
const wallet = new Wallet('0x1c1a49fea9a4ede1dc8e582639f498d41fa3c4a9e2ab2b9d740a4a3ec14e1cbf')

async function depositETH(amount) {
  const tx = await contract.depositETH(wallet.address, {
    value: utils.parse(amount)
  })
  return tx
}

// deposit 1 ETH
depositETH('1').then(console.log)
```

### Deposit ERC20

Like other projects, you must approve ZKSwap's main contract address to spend your ERC20 tokens in order to deposit. Be careful for those tokens that has limit on changing allowance (See <https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729>).

Example code:

```javascript
import { Wallet, Contract, utils } from 'ethers'

const contract = new Contract('0x8ECa806Aecc86CE90Da803b080Ca4E3A9b8097ad', ABI, wallet)
const wallet = new Wallet('0x1c1a49fea9a4ede1dc8e582639f498d41fa3c4a9e2ab2b9d740a4a3ec14e1cbf')

async function depositERC20(amount, tokenAddress) {
  const tokenContract = new Contract(tokenAddress, ERC20_ABI, wallet)
  // check allowance
  const allowance = await tokenContract.allowance(wallet.address, MAIN_CONTRACT_ADDRESS)
  let nonce
  if (allowance.lt(utils.parse(amount)) {
    // approve
    const MAX_AMOUNT = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
    const approveTx = await tokenContract.allow(MAIN_CONTRACT_ADDRESS, MAX_AMOUNT)
    nonce = approveTx.nonce + 1
  }
  const tx = await contract.depositERC20(tokenAddress, utils.parse(amount), wallet.address, {
    nonce
  })
  return tx
}

// deposit 100 ZKS
depositERC20('100', '0xe4815ae53b124e7263f08dcdbbb757d41ed658c6').then(console.log)
```

## Layer-2

When submitting transaction to ZKSwap, the API requires 3 fields: `tx`, `signature` and `fastProcessing`.In the following docs, `Signed Transaction` refers to the `tx` field and `ETH Signature` refers to the `signature` field.

### Private Key

Sign the following message with Layer-1's private key to get Layer-2's seed. And use [zkSync's crypto libraries](https://zksync.io/api/sdk/crypto.html) to get private key.

{% tabs %}
{% tab title="Plain Text" %}

```
Access ZKSwap account.

Only sign this message for a trusted client!
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const msg = 'Access ZKSwap account.\n\nOnly sign this message for a trusted client!'
```

{% endtab %}
{% endtabs %}

Here's a full example of getting private key using [zksync-crypto](https://www.npmjs.com/package/zksync-crypto) in JavaScript.

```javascript
import { Wallet, Contract, utils } from 'ethers'
import { privateKeyFromSeed, private_key_to_pubkey_hash } from 'zksync-crypto'

const wallet = new Wallet('0x1c1a49fea9a4ede1dc8e582639f498d41fa3c4a9e2ab2b9d740a4a3ec14e1cbf')

async function getPrivateKey() {
    const msg = 'Access ZKSwap account.\n\nOnly sign this message for a trusted client!'
    const signature = await wallet.signMessage(msg)
    const seed = utils.arrayify(signature)

    // Get private key
    const privateKey = privateKeyFromSeed(seed)
    
    return privateKey
}

getPrivateKey().then(console.log)
```

### Public Key Hash

After getting private key, you will need to register you publick key hash to ZKSwap so that it can verify transations that you sent.

```javascript
import { utils } from 'ethers'
import { private_key_to_pubkey_hash } from 'zksync-crypto'

const pubKeyHash = `sync:${utils.hexlify(private_key_to_pubkey_hash(privateKey)).substr(2)}`
```

### Signature

Before submit transaction to ZKSwap, you need to sign the the transaction data.

```javascript
import { utils } from 'ethers'
import { sign_musig } from 'zksync-crypto'

function signMessage(privateKey, msgBytes) {
    const signaturePacked = sign_musig(privateKey, msgBytes)
    
    const pubKey = utils.hexlify(signaturePacked.slice(0, 32)).substr(2)
    const signature = utils.hexlify(signaturePacked.slice(32)).substr(2)
    
    return {
        pubKey,
        signature
    }
}

const msgBytes = utils.concat([type, accountId, ...etc])
const signature = signMessage(privateKey, msgBytes)

```

### Change Public Key

After the account has been "registered" on ZKSwap (via transfer or deposit), you can change the account's `pubKeyHash` in order to make any transaction on Layer-2. This is a special transaction that you don't need to sign it with Layer-2's private key.

**Transaction Fields**

| **Field**    | Type    | Comment              |
| ------------ | ------- | -------------------- |
| type         | string  | ChangePubKey         |
| accountId    | number  | Your account ID.     |
| account      | address | Your address.        |
| newPkHash    | number  | The public key hash. |
| nonce        | number  | Your current nonce.  |
| ethSignature | string  | Layer-1 signature    |

**Signed Transaction Example**

```javascript
{
    "type": "ChangePubKey",
    "accountId": 83670,
    "account": "0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF",
    "newPkHash": "sync:83f62ba777515089eb905a375f77f59ddfada116",
    "nonce": 0,
    "ethSignature": "0x66c1ef3611a634e400301375b291a0835b0e31237273e1bdab45acc3ef27c761674fd5e5a706566e5175e8e18306f5b8d1d36016f3894e84d527c3c97e92bcf71c"
}
```

**ETH Signature**

{% tabs %}
{% tab title="Message Template" %}

```
Register ZKSwap pubkey:

{pubKeyHash}
nonce: {hexlifiedNonce}
account id: {hexlifiedAccountId}

Only sign this message for a trusted client!
```

{% endtab %}

{% tab title="Message Example" %}

```
Register ZKSwap pubkey:

83f62ba777515089eb905a375f77f59ddfada116
nonce: 0x00000000
account id: 0x000146d6

Only sign this message for a trusted client!
```

{% endtab %}

{% tab title="Signature" %}

```
0x66c1ef3611a634e400301375b291a0835b0e31237273e1bdab45acc3ef27c761674fd5e5a706566e5175e8e18306f5b8d1d36016f3894e84d527c3c97e92bcf71c
```

{% endtab %}
{% endtabs %}

**NOTE**: The `{pubKeyHash}` in the above message doesn't contain 0x as prefix. The `{hexlifiedNonce}` and `{hexlifiedAccountId}` has 4-bytes length with 0 padding in the start and 0x as prefx. See example for reference.

### Transfer

**Transaction Fields**

| Bytes Order | **Field** | Type    | Bytes Length | Comment                                  | Bytes Example                                |
| ----------- | --------- | ------- | ------------ | ---------------------------------------- | -------------------------------------------- |
| 0           | type      | string  | 1            | Transfer                                 | `0x05`                                       |
| 1           | accountId | number  | 4            | Your account ID.                         | `0x0000053a`                                 |
| 2           | from      | address | 20           | Your address.                            | `0x026a25efbcefb2e481d005e4f00ccced0af511ff` |
| 3           | to        | address | 20           | The target address you want to transfer. | `0x961b513dfd3e363c238e0f98219ee02552a847bd` |
| 4           | token     | number  | 2            | The ID of the token.                     | `0x000a`                                     |
| 5           | amount    | string  | 5            | The packed amount you want to transfer.  | `0x4a817c8008`                               |
| 6           | feeToken  | number  | 1            | The ID of fee token.                     | `0x0a`                                       |
| 7           | fee       | string  | 2            |                                          | `0x0000`                                     |
| 8           | chainId   | number  | 1            | 11 for mainnet, 128 for ropsten.         | `0x0b`                                       |
| 9           | nonce     | number  | 4            | Your current nonce.                      | `0x00000001`                                 |
| -           | signature | object  |              | Contains your `pubKey` and signature.    |                                              |

**Full Bytes Example**

```
0x050000053a026a25efbcefb2e481d005e4f00ccced0af511ff961b513dfd3e363c238e0f98219ee02552a847bd000a4a817c80080a00000b00000001
```

**Signed Transaction Example**

```javascript
{
    "type": "Transfer",
    "accountId": 1338,
    "from": "0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF",
    "to": "0x961b513dfd3e363c238e0f98219ee02552a847bd",
    "token": 10,
    "amount": "1000000000000000000",
    "feeToken": 10,
    "fee": "0",
    "chainId": 11,
    "nonce": 1,
    "signature": {
        "pubKey": "110ffd569daaee30068fc3c85922d1237f63a41d4749d464b883131e92369204",
        "signature": "7db4f4ce33abf89cbccaff96ae0651c79043dcf965893de71e7388163ec57883b2d4ef9bf264346ceff69f9ba8dfe8624d1fad9a452acf10a5d15f956a0a7b03"
    }
}
```

**ETH Signature**

{% tabs %}
{% tab title="Message Template" %}

```
Transfer {readableAmount} {tokenSymbol}
To: {to}
Chain Id: {chainId}
Nonce: {nonce}
Fee: {readableFee} {feeTokenSymbol}
Account Id: {accountId}
```

{% endtab %}

{% tab title="Message Example" %}

```
Transfer 1.0 ZKS
To: 0x961b513dfd3e363c238e0f98219ee02552a847bd
Chain Id: 11
Nonce: 1
Fee: 0.0 ZKS
Account Id: 1338
```

{% endtab %}

{% tab title="Signature" %}

```javascript
{
    "type": "EthereumSignature",
    "signature": "0xbf8fa93e7da866aa3acb07a6a826e5e61195eba04e3c72a4f02b8fc8221da1f764363817968576013ca515ffe5e1104b5890937150883f3304d0738777af915b1c"
}
```

{% endtab %}
{% endtabs %}

### Withdraw

**Transaction Fields**

| Bytes Order | **Field** | Type    | Bytes Length | Comment                                     | Bytes Example                                |
| ----------- | --------- | ------- | ------------ | ------------------------------------------- | -------------------------------------------- |
| 0           | type      | string  | 1            | Withdraw                                    | `0x03`                                       |
| 1           | accountId | number  | 4            | Your account ID.                            | `0x0000053a`                                 |
| 2           | from      | address | 20           | Your address.                               | `0x026a25efbcefb2e481d005e4f00ccced0af511ff` |
| 3           | to        | address | 20           | The target address you want to withdraw to. | `0x026a25efbcefb2e481d005e4f00ccced0af511ff` |
| 4           | token     | number  | 2            | The ID of the token you want to withdraw.   | `0x000a`                                     |
| 5           | amount    | string  | 16           | The amount you want to withdraw.            | `0x00000000000000000de0b6b3a7640000`         |
| 6           | feeToken  | number  | 1            | The ID of fee token.                        | `0x0a`                                       |
| 7           | fee       | string  | 2            |                                             | `0x4bf0`                                     |
| 8           | chainId   | number  | 1            | 11 for mainnet, 128 for ropsten.            | `0x0b`                                       |
| 9           | nonce     | number  | 4            | Your current nonce.                         | `0x00000002`                                 |
| -           | signature | object  |              | Contains your `pubKey` and signature.       |                                              |

**Full Bytes Example**

```
0x030000053a026a25efbcefb2e481d005e4f00ccced0af511ff026a25efbcefb2e481d005e4f00ccced0af511ff000a00000000000000000de0b6b3a76400000a4bf00b00000002
```

**Signed Transaction Example**

```javascript
{
    "type": "Withdraw",
    "accountId": 1338,
    "from": "0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF",
    "to": "0x026a25efbcefb2e481d005e4f00ccced0af511ff",
    "token": 10,
    "amount": "1000000000000000000",
    "feeToken": 10,
    "fee": "6070000000000000000",
    "chainId": 11,
    "nonce": 2,
    "signature": {
        "pubKey": "110ffd569daaee30068fc3c85922d1237f63a41d4749d464b883131e92369204",
        "signature": "68bb8413edc0182812aa90481ff46f0514df9d5d6b5703338f1a292682caad9b04cac623f95b9d26fa31d4a9330ba35b5746fd697853a0512f92b00692fe6d00"
    }
}
```

**ETH Signature**

{% tabs %}
{% tab title="Message Template" %}

```
Withdraw {readableAmount} {tokenSymbol}
To: {to}
Chain Id: {chainId}
Nonce: {nonce}
Fee: {readableFee} {feeTokenSymbol}
Account Id: {accountId}
```

{% endtab %}

{% tab title="Message Example" %}

```
Withdraw 3.4226556417 ZKS
To: 0x026a25efbcefb2e481d005e4f00ccced0af511ff
ChainId 10
Nonce: 2
Fee: 1.577 ZKS
Account Id: 83670
```

{% endtab %}

{% tab title="Signature" %}

```javascript
{
    "type": "EthereumSignature",
    "signature": "0x0440667d6a694b76e5f3a51fa3981a3db95bfc7d3feeb301f403ea6f3bef01d32c9e06920f7b13edd92a6cb22f49d6709fb4f9d41efc09b0a094173b6bbb4f121b"
}
```

{% endtab %}
{% endtabs %}

### Swap

#### **Fee**

Let's take swap token A for token B as example. There are two cases:

1. If A is a fee token, the fee token of swap is A. The number of fee is calculated by `amountIn * 5 / 9995`
2. If A is not a fee token, the fee token of swap is B. The number of fee is `amountOut * 5 /10000`. It's not `amountOutMin`. `amountOut` equals `amountOutMin` then slipplage is 0.

**Transaction Fields**

| Bytes Order | **Field**    | Type    | Bytes Length | Comment                                   | Bytes Example                                |
| ----------- | ------------ | ------- | ------------ | ----------------------------------------- | -------------------------------------------- |
| 0           | type         | string  | 1            | Swap                                      | `0x0b`                                       |
| 1           | accountId    | number  | 4            | Your account ID.                          | `0x0000053a`                                 |
| 2           | from         | address | 20           | Your address.                             | `0x026a25efbcefb2e481d005e4f00ccced0af511ff` |
| 3           | to           | address | 20           | The pair's address.                       | `0xaa45c964e21eafb38574e9d000adbaf85acfbb80` |
| 4           | tokenIn      | number  | 2            | The ID of the token you want to swap in.  | `0x000a`                                     |
| 5           | amountIn     | string  | 5            | The amount you want to swap in.           | `0x94efe63009`                               |
| 6           | tokenOut     | number  | 2            | The ID of the token you want to swap out. | `0x0000`                                     |
| 7           | amountOutMin | string  | 5            | The minimum amount  you want to swap out. | `0x25004d47c6`                               |
| 8           | feeToken     | number  | 1            | The ID of fee token.                      | `0x0a`                                       |
| 9           | fee          | string  | 2            |                                           | `0x7d0d`                                     |
| 10          | chainId      | number  | 1            | 11 for mainnet, 128 for ropsten.          | `0x0b`                                       |
| 11          | nonce        | number  | 4            | Your current nonce.                       | `0x00000003`                                 |
| -           | signature    | object  |              | Contains your `pubKey` and signature.     |                                              |

**Full Bytes Example**

```
0x0b0000053a026a25efbcefb2e481d005e4f00ccced0af511ffaa45c964e21eafb38574e9d000adbaf85acfbb80000a94efe63009000025004d47c60a7d0d0b00000003
```

**Signed Transaction Example**

```javascript
{
    "type": "Swap",
    "accountId": 1338,
    "from": "0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF",
    "to": "0xaa45c964e21eafb38574e9d000adbaf85acfbb80",
    "tokenIn": 10,
    "tokenOut": 0,
    "amountIn": "19990000000000000000",
    "amountOutMin": "4966214206000000",
    "feeToken": 10,
    "fee": "10000000000000000",
    "chainId": 11,
    "nonce": 3,
    "signature": {
        "pubKey": "110ffd569daaee30068fc3c85922d1237f63a41d4749d464b883131e92369204",
        "signature": "3c6c2059ab0e929ed18d6ad4fbbf1cddce0e84b0cb9537069456b16cd01f33a2bc5391f8f7e1b9ae8fdff4c5d05856709e6bfd0e9200f5293386cf1aa6b39c00"
    }
}
```

**ETH Signature**

{% tabs %}
{% tab title="Message Template" %}

```
Swap {readableAmontIn} {tokenInSymbol}
Minimum: {readableAmontOutMin} {tokenOutSymbol}
To: {pairAddress}
Chain Id: {chainId}
Nonce: {nonce}
Fee: {readableFee} {feeTokenSymbol}
Account Id: {accountId}
```

{% endtab %}

{% tab title="Message Example" %}

```
Swap 19.99 ZKS
Minimum: 0.004966214206 ETH
To: 0xaa45c964e21eafb38574e9d000adbaf85acfbb80
Chain Id: 11
Nonce: 3
Fee: 0.01 ZKS
Account Id: 1338
```

{% endtab %}

{% tab title="Signature" %}

```javascript
{
    "type": "EthereumSignature",
    "signature": "0x66ca505f09e2dbd2aaaa809cac3ec7085ea7831ec58c695566190588a2ced45c0d7e1c235840dd3f547d54ad87e6740bb3d299a89d36460b9eb1e56b25456ef41b"
}
```

{% endtab %}
{% endtabs %}

### Add Liquidity

**Transaction Fields**

| Bytes Order | **Field**      | Type    | Bytes Length | Comment                                                    | Bytes Example                                |
| ----------- | -------------- | ------- | ------------ | ---------------------------------------------------------- | -------------------------------------------- |
| 0           | type           | string  | 1            | AddLiquidity                                               | `0x09`                                       |
| 1           | accountId      | number  | 4            | Your account ID.                                           | `0x0000053a`                                 |
| 2           | from           | address | 20           | Your address.                                              | `0x026a25efbcefb2e481d005e4f00ccced0af511ff` |
| 3           | to             | address | 20           | The pair's address.                                        | `0xaa45c964e21eafb38574e9d000adbaf85acfbb80` |
| 4           | tokenA         | number  | 2            | The ID of token A.                                         | `0x0000`                                     |
| 5           | amountADesired | number  | 5            | The amount of token A you want to add to the pair.         | `0xc2cf6f3245`                               |
| 6           | amountAMin     | string  | 5            | The minimum amount of Token A you want to add to the pair. | `0xb911dcd625`                               |
| 7           | tokenB         | number  | 2            | The ID of the token B.                                     | `0x000a`                                     |
| 8           | amountBDesired | string  | 5            | The amount of token B you want to add to the pair.         | `0x4a817c8009`                               |
| 9           | amountBMin     | string  | 5            | The minimum amount of Token B you want to add to the pair. | `0x46c7cfe009`                               |
| 10          | tokenLiquidity | number  | 2            | The pair ID.                                               | `0x4002`                                     |
| 11          | feeToken       | number  | 1            | The ID of fee token.                                       | `0x0a`                                       |
| 12          | fee            | string  | 2            |                                                            | `0x0000`                                     |
| 13          | chainId        | number  | 1            | 11 for mainnet, 128 for ropsten.                           | `0x0b`                                       |
| 14          | nonce          | number  | 4            | Your current nonce.                                        | `0x00000004`                                 |
| -           | signature      | object  |              | Contains your `pubKey` and signature.                      |                                              |

**Full Bytes Example**

```
0x090000053a026a25efbcefb2e481d005e4f00ccced0af511ffaa45c964e21eafb38574e9d000adbaf85acfbb800000c2cf6f3245b911dcd625000a4a817c800946c7cfe00940020a00000b00000004
```

**Signed Transaction Example**

```javascript
{
    "type": "AddLiquidity",
    "accountId": 1338,
    "from": "0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF",
    "to": "0xaa45c964e21eafb38574e9d000adbaf85acfbb80",
    "tokenA": 0,
    "tokenB": 10,
    "tokenLiquidity": 16386,
    "amountADesired": "2614699457800000",
    "amountBDesired": "10000000000000000000",
    "amountAMin": "2483964484900000",
    "amountBMin": "9500000000000000000",
    "feeToken": 10,
    "fee": "0",
    "chainId": 11,
    "nonce": 4,
    "signature": {
        "pubKey": "110ffd569daaee30068fc3c85922d1237f63a41d4749d464b883131e92369204",
        "signature": "3506a865b8a0871b706a620abbf7978760f76670c2d563f059d217890349988dd7a37d1cea3f67d5ca691453dd45d282141acac3f4dafb9f7a44b1dda3e0ca00"
    }
}
```

**ETH Signature**

{% tabs %}
{% tab title="Message Template" %}

```
AddLiquidity {pairSymbol}
Desired: {readableAmontA} {tokenASymbol} {readableAmontB} {tokenBSymbol}
Minimum: {readableAmontAMin} {tokenASymbol} {readableAmontBMin} {tokenBSymbol}
To: {pairAddress}
Chain Id: {chainId}
Nonce: {nonce}
Fee: {readableFee} {feeTokenSymbol}
Account Id: {accountId}
```

{% endtab %}

{% tab title="Message Example" %}

```
AddLiquidity liquidity_0_10
Desired: 0.0026146994578 ETH 10.0 ZKS
Minimum: 0.0024839644849 ETH 9.5 ZKS
To: 0xaa45c964e21eafb38574e9d000adbaf85acfbb80
Chain Id: 11
Nonce: 4
Fee: 0.0 ZKS
Account Id: 1338
```

{% endtab %}

{% tab title="Signature" %}

```javascript
{
    "type": "EthereumSignature",
    "signature": "0x20c1c26e8f678220189f0a4a444e1686e969faa536a17abc1a30a113d6e4bfc12aa88a2075693857ea410f439d28467b01666bcb01d1b6bb7b8ce3641bd6daea1b"
}
```

{% endtab %}
{% endtabs %}

### Remove Liquidity

**Transaction Fields**

| Bytes Order | **Field**       | Type    |    | Comment                                                         | Bytes Examplle                               |
| ----------- | --------------- | ------- | -- | --------------------------------------------------------------- | -------------------------------------------- |
| 0           | type            | string  | 1  | RemoveLiquidity                                                 | `0x0a`                                       |
| 1           | accountId       | number  | 4  | Your account ID.                                                | `0x0000053a`                                 |
| 2           | from            | address | 20 | Your address.                                                   | `0x026a25efbcefb2e481d005e4f00ccced0af511ff` |
| 3           | to              | address | 20 | The pair's address.                                             | `0xaa45c964e21eafb38574e9d000adbaf85acfbb80` |
| 4           | tokenA          | number  | 2  | The ID of token A.                                              | `0x0000`                                     |
| 5           | amountAMin      | string  | 5  | The minimum amount of Token A you want to remove from the pair. | `0xb96855c485`                               |
| 6           | tokenB          | number  | 2  | The ID of the token B.                                          | `0x000a`                                     |
| 7           | amountBMin      | string  | 5  | The minimum amount of Token B you want to remove from the pair. | `0x46a6e21049`                               |
| 8           | feeToken        | number  | 1  | The ID of fee token.                                            | `0x0a`                                       |
| 9           | fee             | string  | 2  |                                                                 | `0x0000`                                     |
| 10          | tokenLiquidity  | number  | 2  | The pair ID.                                                    | `0x4002`                                     |
| 11          | amountLiquidity | string  | 5  | The amount of LP token you want to remove.                      | `0x77e80cdba7`                               |
| 12          | chainId         | number  | 2  | 11 for mainnet, 128 for ropsten.                                | `0x0b`                                       |
| 13          | nonce           | number  | 4  | Your current nonce.                                             |                                              |
| -           | signature       | object  |    | Contains your `pubKey` and signature.                           |                                              |

**Full Bytes Example**

```
0x0a0000053a026a25efbcefb2e481d005e4f00ccced0af511ffaa45c964e21eafb38574e9d000adbaf85acfbb800000b96855c485000a46a6e210490a0000400277e80cdba70b00000005
```

**Signed Transaction Example**

```javascript
{
    "type": "RemoveLiquidity",
    "accountId": 1338,
    "from": "0x026A25EfbcEFb2e481d005E4F00Ccced0AF511FF",
    "to": "0xaa45c964e21eafb38574e9d000adbaf85acfbb80",
    "tokenA": 0,
    "tokenB": 10,
    "amountAMin": "2488498128400000",
    "amountBMin": "9482735746000000000",
    "tokenLiquidity": 16386,
    "amountLiquidity": "160935707810000000",
    "feeToken": 10,
    "fee": "0",
    "chainId": 11,
    "nonce": 5,
    "signature": {
        "pubKey": "110ffd569daaee30068fc3c85922d1237f63a41d4749d464b883131e92369204",
        "signature": "bf0e5c3639e9f9f837e2d141fa9481da8e11574001dbe8cd81cb3005c9cac69ae05655d416cd53bedd27142235ad5743e9f26b66ac8643d859d0c8caf149a700"
    }
}
```

**ETH Signature**

{% tabs %}
{% tab title="Message Template" %}

```
RemoveLiquidity {readableLiquidityAmount} {pairSymbol}
Minimum: {readableAmontAMin} {tokenASymbol} {readableAmontBMin} {tokenBSymbol}
To: {pairAddress}
Chain Id: {chainId}
Nonce: {nonce}
Fee: {readableFee} {feeTokenSymbol}
Account Id: {accountId}
```

{% endtab %}

{% tab title="Message Example" %}

```
RemoveLiquidity 0.16093570781 liquidity_0_10
Minimum: 0.0024884981284 ETH 9.482735746 ZKS
To: 0xaa45c964e21eafb38574e9d000adbaf85acfbb80
Chain Id: 11
Nonce: 5
Fee: 0.0 ZKS
Account Id: 1338
```

{% endtab %}

{% tab title="Signature" %}

```
{
    "type": "EthereumSignature",
    "signature": "0x85ce1409808a56b4522b6787d397d4b5d04a926e701a72b1388fff74f447650b1789c6bb7487b638bb1f6100faaa318b37311d831f07252bd0971331e61b8ad51b"
}
```

{% endtab %}
{% endtabs %}


