Wrapping wETH

Hello team! :wave:

I'm trying to make a wETH (Polygon) wrapper with Ardor.

wETH has 18 decimal places, Ardor only allows 8 decimal places.

What do you think is the best solution to solve this? Truncate to 8 decimal places from Solidity and then send those assets, right?

Thank you!

1 Like

yes, this looks like the best solution.

1 Like

I have come across in the documentation with:

But it only makes the similarity of ERC-20 with IGNIS.
Is there already an ERC-20 bridge with the Ignis chain?

1 Like

I'm not aware of such bridge and I'm not sure if the instructions in this page can be implemented as a smart contract. The smart contract must be able to call the Ardor API. Not sure if possible.

I am trying to adapt the ERC-1155 bridge to work with the ERC-20.
Our goal is to send wETH from Polygon to Ardor.

The problem I currently have is here:

Code:


Error:

2023-04-11 18:47:30 SEVERE: pool-4-thread-2 Task com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$ApprovalTask@34f5329e failed
java.lang.NullPointerException
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$PegContext.getEthContractReadOnly(AssetsErc20.java:911)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$ApprovalTask.execute(AssetsErc20.java:1041)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$Task.run(AssetsErc20.java:998)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
2023-04-11 18:47:30 INFO: qtp1054932644-90 MB-Wrap: !completedWrapIds.get().contains(id)
2023-04-11 18:47:30 INFO: qtp1054932644-90 Unwrap task (0317375c4df0a02861a7a2b0bf6e33d4d14d764dc9ade65f2d76820d9630cf25,18) started by transaction 0x82df5f03f8cce59fe12dc002d974115c96c65d2d8b269b1ea4a6c5f0ab24bb24
2023-04-11 18:47:30 WARNING: pool-4-thread-1 MB-Bridge | mbWrapTask + execute | ENSURE_ACCOUNT_WITHDRAWER_ROLE
2023-04-11 18:47:30 INFO: pool-4-thread-2 Task (e6e81c59e72bdb51d8e65240b90911184913956128520e73c0807db5e93d1d54,2) failed with error java.lang.NullPointerException
2023-04-11 18:47:30 INFO: pool-4-thread-2 Task (82ab044f51d2a78f81f1de147e383a8cb6afd7060e4620f43f68300a49002fd9,2) failed with error java.lang.NullPointerException
2023-04-11 18:47:30 INFO: pool-4-thread-2 Task (0317375c4df0a02861a7a2b0bf6e33d4d14d764dc9ade65f2d76820d9630cf25,18) failed with error java.lang.NullPointerException

I don't understand the NullPointerException, the variable should not be empty. The class should return fine. IERC20 is the openzeppelin standard.

I'm trying to send to the blocking address to get them all under control.

Thanks for your advice, I really appreciate it! @petko.petkov

I cannot tell from here, need to see the full code. Do you call PegContext.init ?

I think yes, you can check the code. Now is open-source: GitHub - MythicalBeings/erc20-bridge

Thank you! :pray:

I have created a tWETH token that I use for testing, if you need to send me your wallet.

I cannot build the project for a reason which is not clear to me:

In plugin 'org.web3j.solidity.gradle.plugin.SolidityPlugin' type 'org.web3j.solidity.gradle.plugin.SolidityResolve' property 'sources' is annotated with @InputFiles but missing a normalization strategy.

I don't see why ethContract would be null. Could you attach the logs you get on your side?

2 Likes

maybe add a log before pegContext.init(params, threadPool);

Strange... nothing was changed in the plugin.

Try this project, maybe the .gitignore deleted some important files: WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free

There are apparently no errors.

java.lang.NoSuchMethodError: 'void com.jelurida.web3j.utils.TransactionalContract.<init>(java.lang.String, org.web3j.protocol.Web3j, org.web3j.tx.TransactionManager, org.web3j.tx.gas.ContractGasProvider)'
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$PegContext.init(AssetsErc20.java:764)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20.init(AssetsErc20.java:288)
	at nxt.addons.ContractAndSetupParameters.init(ContractAndSetupParameters.java:65)
	at nxt.addons.ContractRunner.lambda$processBlock$10(ContractRunner.java:529)
	at java.base/java.util.HashMap.forEach(HashMap.java:1337)
	at nxt.addons.ContractRunner.processBlock(ContractRunner.java:517)
	at nxt.util.Listeners.notify(Listeners.java:48)
	at nxt.blockchain.BlockchainProcessorImpl.pushBlock(BlockchainProcessorImpl.java:1493)
	at nxt.blockchain.BlockchainProcessorImpl.processPeerBlock(BlockchainProcessorImpl.java:1184)
	at nxt.peer.BlockInventory.lambda$processRequest$1(BlockInventory.java:141)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
2023-04-17 09:52:44 SEVERE: pool-16-thread-2 Task com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$ApprovalTask@467a2a81 failed
java.lang.NullPointerException
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$PegContext.getEthContractReadOnly(AssetsErc20.java:914)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$ApprovalTask.execute(AssetsErc20.java:1044)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$Task.run(AssetsErc20.java:1001)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

UPDATE
I think I have discovered the error.
I modified "TransactionalContract" not to receive the first parameter "isMinter" as it will not be used.

For some reason it wouldn't update and therefore couldn't find a three-parameter constructor.

Now it initialises correctly.

Now the error is the following, I guess it is not updated again:

2023-04-17 10:22:38 SEVERE: pool-4-thread-2 Task com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$ApprovalTask@3d7fa1ca failed
java.lang.ClassCastException: class com.jelurida.web3j.generated.IERC1155 cannot be cast to class com.jelurida.web3j.generated.IERC20 (com.jelurida.web3j.generated.IERC1155 and com.jelurida.web3j.generated.IERC20 are in unnamed module of loader 'app')
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$PegContext.getEthContractReadOnly(AssetsErc20.java:914)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$ApprovalTask.execute(AssetsErc20.java:1044)
	at com.jelurida.ardor.contracts.interchain.eth.AssetsErc20$Task.run(AssetsErc20.java:1001)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

It is now IERC20, not IERC1155.

Any way to update all references?

OK, the nullpointer is caused by the java.lang.NoSuchMethodError: 'void com.jelurida.web3j.utils.TransactionalContract.<init> as you already found.

The java.lang.ClassCastException exception: apparently TransactionalContract.getReadOnly returns an ERC1155 instance instead of ERC20 instance. You probably have the erc1155-0.0.1.jar somewhere in the classpath and the TransactionalContract is loaded from it instead of from erc20.jar. Or you didn't compile the erc20 project properly. Cannot say from here. Try to restart everything.

Hello Petko!

Sorry for the delay in replying.

I have tried to recompile the whole project and there is no solution.
I don't understand why it is detecting ERC1155, I have searched the whole project and there is no mention of it.

I have tried rebooting the whole system and re-uploading all the libraries several times.

You have the code, right? I have a virtual machine with the whole environment set up, would you like me to share it with you?

ok, send me the vm image

1 Like