In this example, we're going to show you how to send xDai to Dai using their TokenBridge and Etherspot.
Before we continue...
We're going to be using two Etherspot SDK instances here:
A mainnet version
We will use this instance to send our DAI from and ETH to pay the gas fees.
A xDai version
We will use this instance to receive our xDai on the xDai chain.
Make sure you've checked out Supported Ethereum Chains before you continue as we also show you the code to instantiate mainnet and xDai versions of the SDK. Remember to use the same private key for both SDK instances to get the same Ethereum address on both mainnet and xDai.
This example use case is more complex than the previous guide in this series: DAI - xDai Bridge, but completes the cycle of DAI
Please make sure your that your xDai Etherspot address is funded with enough xDAI to pay the gas fees required.
Sending xDai to TokenBridge
The first step in our journey to change xDai back to DAI is to send our xDai, using the xDai version of the Etherspot SDK, to the xDai TokenBridge.
Let's define our required variables:
* Note: Make sure that your `mainnet` and `xDai`
* instances of the Etherspot SDK are available here.
* For the purposes of this demonstration, we're going
// Visit https://etherscan.io/address/0x7e7669bdff02f2ee75b68b91fb81c2b38f9228c2#code and scroll down to Contract ABI and copy the whole code and paste it in a JSON file and import it to this variable.