Patex Docs
Search
K

CryptoExchange Tutorial

# Connecting to Patex

You connect to Patex the same way you do to Ethereum, by connecting to a JSON RPC endpoint. After the Bedrock upgrade, we support EIP 1559.

ETH balance

In Bedrock ETH is used precisely the way it is used in L1 Ethereum.

Token addresses

The ERC-20 contract address for a token on Patex may be different from the address for the same token on Ethereum.
For example, looking at the PUT-1 token, we get these addresses:
ChainID
Network
Address
5
Sepolia (test network)
0x04459A4D7d1d7BFb48EBc635e30169D50D56EEAC
471100
Patex Sepolia (test network)
0xCddD6D3d4024535CceeA408EAb8cd00C8f162e6D
To get the total PUT-1 balance of a user that uses Patex you need to:
  1. 1.
    Connect to a standard Ethereum endpoint and send a balanceOf query to address 0x04459A4D7d1d7BFb48EBc635e30169D50D56EEAC.
  2. 2.
    Connect to an Patex endpoint and send a balanceOf query to address 0xCddD6D3d4024535CceeA408EAb8cd00C8f162e6D.

# Deposits and withdrawals within Patex

The ERC-20 contracts on Patex function the same way they do on Ethereum, so you can use your existing code for withdrawals and deposits. Just connect to an Patex endpoint.

Transaction fees

Most of the cost of an Patex transaction is not the gas consumed by the transaction itself (which is priced in most cases at 0.001 gwei), but the cost of writing the transaction in Ethereum. That cost is deducted automatically from the user's balance on Patex. If you charge your users the cost of withdrawals, you have to account for it.
You can read more about this subject here. The relevant code is here (opens new window).

# Deposits and withdrawals across chains

As a centralized exchange, there will be times that withdrawals of ETH or an ERC-20 token on either Patex or Ethereum exceed deposits and you need to transfer assets. To do that you use a bridge or a gateway. We have a L1 standard bridge that receives assets on L1 (Ethereum mainnet), and mints the equivalent asset on Patex. When a user wants to withdraw the assets back to L1, the bridge burns the asset on L2 and releases it to the user on L1. If you want to use this bridge automatically, follow this tutorial for ETH (opens new window) or this one for ERC-20 tokens (opens new window).
Note that while L1 to L2 transactions typically take minutes, L2 to L1 transaction on the gateway require a seven day challenge period.
Alternatively, you can use a third party bridge. These bridges usually rely on liquidity pools to allow for faster withdrawals and support multiple L2 chains. However, their token selection might be more limited and they may not be as decentralized as our gateway.
When an ERC-20 token does not have an Patex equivalent you can create one. If there is no need for custom business logic, you can follow the steps in this tutorial (opens new window). If you need to implement some kind of custom logic, see this tutorial (opens new window).
Last modified 8mo ago