Wrapped ERC-20 Token Issue

Hi,

We are having some issues with our new wrapped ERC-20 token. It was understood that if we transferred the underlying token to the wrapped ERC-20 token contract that an automatic process would occur that sends the equivalent amount of wrapped ERC-20 to the sending wallet. However, this did not occur.

Wrapped Token: https://etherscan.io/address/0x721c69f5eb88e52a3c4741d78b18ef4141e9a108
Underlying Token: https://etherscan.io/token/0x4e7946121b238a4f6971c15aea1f8c198c14b387

Can someone help us debug this? We see the ICEE token on the contract, however the wICEE supply did not increase nor did the wICEE return to the sending wallet that sent along the 5,000 ICEE.

1 Like

Can you please explain what you mean by "transferred" here?

Specifically, which function did you call and on which contract?

Please also provide a link to the related transaction on etherscan, if you happen to have one at hand.

1 Like

Perhaps you meant to say that you've specified the address of your original token contract as input argument to the constructor of the wrapped token contract when you deployed the latter?

Anyways, I believe that you can execute this from an offchain script:

Read: yourBalance = originalTokenContract.balanceOf(yourWallet.address)
Send: originalTokenContract.approve(wrappedTokenContract.address, yourBalance)
Send: wrappedTokenContract.withdrawTo(yourWalletAddress, yourBalance)

More generally, anyone holding your tokens can use function depositFor and function withdrawTo on the new contract.

1 Like

Hi, I transferred two ways to test, one was from a wallet that owned ICEE via MetaMask and another was from the actual ICEE contract to the wICEE contract. Here is one of the the transactions https://etherscan.io/tx/0x49b5fb826e7f36f7adc083b98a0df37299672463c48b9db77f9adaa13141efe0

Thanks so much for your response and time.

1 Like

I thought that using the depositFor would be the option, but when I tried to use this, the gas was really high and a bunch of red messages showed up in Metamask, so I figured something was wrong. I tried to run this using the contract owner wallet along with the ICEE token owner wallet. And both results were the same.

1 Like

But, the real question is, why didn't the wICEE get deposited to the sending wallet when ICEE was sent to the wICEE contract? Shouldn't this be an automatic process and the sending wallet should have wICEE in it amounting to the value sent, correct?

1 Like

Ah, I think I see. I didn't approve the wICEE to spend the ICEE and this may be causing the issues. I just approved. Let's see!

1 Like

Did you approve beforehand?

For example, as I suggested in my original answer:

@barakman I just approved. I'm going to try to send some more tokens to see if it auto wraps now.

Hmm... Here is the new transaction https://etherscan.io/tx/0xf8f4758f0de9a650b30c88a073428b6b586ea8ae79a91749394bd0c6f0a2cfb5 and it doesn't seem that the wICEE wrapped.

The token transferred, but no events were fired according to https://etherscan.io/address/0x721c69f5eb88e52a3c4741d78b18ef4141e9a108#events

With the total number of your token holders being arbitrarily large, it is impossible to execute this within a single transaction (specifically, as part of your wrapped-token-contract deployment transaction).

Let alone the fact that there is no way for the wrapped-token-contract's constructor to know the total list of those token holders to begin with (even if that list happens to be small).

Most likely, this is something left for each token holder to carry out independently and on their expense, (i.e., each token holder will be paying the associated gas cost).

So, there is a way for me to get wICEE from the wICEE contract now? I don't understand what the next steps are. I see there is 5200 ICEE on the wICEE contract now, but how do I get the wICEE version?

Checking your wallet balance on the new contract, it appears to be zero:

If that's not your wallet address, and you do have a balance larger than zero on your wallet, then I suppose that you can use both ERC20 standard transfer function and the wrapper's withdrawTo function (in both cases, after approving the new contract to transfer tokens from your wallet).

I just made some kind of breakthrough. It seems that it let me use the depositFor function now: https://etherscan.io/tx/0xdbaf01bc6a86a8d9f1bbc40565cf4caa20216d935f90666993b2f1470bd6f9a6

Wow! I have 5200 wICEE in my wallet now! Well, I'm not totally sure what the process was to make this happen, but it did send me wICEE!

If I were to send this wICEE from my wallet back to the wICEE contract, would the total supply increase?

I recommend reading ERC20Wrapper official documentation.

1 Like

Thanks again for the help @barakman. I will take a look at the official documentation to learn more.

1 Like