Sollet Wallet — Convert USDT from ERC-20 to Solana Blockchain (Deep Dive)

SHASHANK KUMAR
4 min readJun 2, 2021

The tutorial begins from here:

The problem is there are no error cases mentioned in the above article. I encountered several errors in the execution of the smart contracts and I wasted almost a hundred dollars trying to make it work with firing multiple transactions which failed eventually.

Before jumping to the error case, lets describe the steps. Each conversion of ERC-20 USDT to Solana(SPL) USDT consists of two main steps(transactions):

  1. Invocation of ETH USDT contract approve method with the amount of USDT (as input). This transaction(transaction link) approves the solana bridge to set the maximum limit(to the given input) on the amount of ERC20 USDT that can be swapped to SPL ERC20. If you provide 10 as the input, you cannot convert more than 10(ERC20) USDT to (SPL) USDT using that particular metamask wallet. Remember the limits are associated with each ERC20 wallet(address).
  2. Actual transaction to the Solana Bridge which causes the transaction. The conversion can happen across multiple transactions(for e.g. 3 transactions of 7,2,1). If you exceed more than the conversion limit(set in step 1), this step will fail. There are a lot of technical details behind the scenes but I am trying to keep this as non-technical as possible.

When we use the sollet wallet, both the transactions are initiated using the metamask extension. You can look at etherscan(or metamask extension) for the list of transactions. The care needs to be taken that step 1 has to precede step 2. If you the transactions happen out of order, it can cause some unwanted problems I am going to discuss.

Error Case 1: Step 1 transaction fails or the user cancels the transaction.

This means that the conversion limit is still zero(default value). So, step 2 will definitely fail because you are trying to convert more than the limit(which is zero in this case). Retrying (both) the transactions from the sollet wallet will solve the problem in this case.

Error Case 2:

Step 1 succeeds but Step 2 fails or is cancelled. This is a more challenging problem if you don’t know one technical detail.

Let’s take the inputs in the screenshot.

If step 1 succeeds, your limit is increased to 10 USDT. That means you can convert 10 (erc20) USDT to (SPL) USDT. But, the problem is you cannot increase your limit untill you have spent your limit fully(which is 10$) in this case.

But what happens if you try to repeat the steps 1 & 2 again(remember sollet wallet doesn’t have the option to choose if you want to skip a step). Step 1 if repeated will give you an error(since you haven’t spent your limit of 10$).

There are three cases:

  1. If you input exactly 10$ to swap, the step 2 will most likely succeed since, your wallet is already approved to swap maximum of 10$. The wallet limit reduces to 0. This is the best case scenario because after this, your wallet is just in the default state(limit=0). You can use the sollet wallet again.
  2. If you input more than 10$(say 20$) thinking that the limits will get added up(10+20=30), congratulations, both step 1 and step 2 will fail. This is the most common blunder I made. I wasted several transactions due to this notion that limits get added up. The limit will stay at 10$.
  3. If you input less than 10$(say 5$), step 1 will fail, step 2 will succeed and you wallet limit will reduce by the input(5$) to 5$. But you have to be clear about the limits of your wallet before you start your next transaction.

Remember untill you reduce the current limit of wallet to 0(think about it as resetting the wallet to default state), you cannot increase its limit.

The best way to know the current limit of your wallet:

  1. Go to this link

2. Go to function number 16

Let me explain the inputs:

  1. _owner: you metamask ERC-20 wallet address
  2. Solana bridge Contract address-0xeae57ce9cc1984f202e15e038b964bb8bdf7229a

Output:

the allowance(limit) of the number of USDT (ERC-20) tokens that can be converted to (SPL) USDT. If you observe(in screenshot) that is a huge number(10000000). The actual value is 10000000/1000000 = 10 USDT. Just remove the last 6 zeroes or divide by 1000000.

Once you complete your transactions(particularly step 2) via sollet, the allowance reduces.

If you are not sure about whether you can handle error cases, always remember these steps:

  1. don’t cancel transactions.
  2. Give it enough gas at the start of the transaction so that you don’t need to speed it up(speeding it up however should be fine).
  3. Once both step 1 and step 2 (transactions) are successful, you are good to initiate one more transaction.

--

--