Working with bridge (ERC-1155)

Hello team!

I have a lot of doubts about bridge:

  1. About the JSON file...
  • Should they be random strings, perhaps mnemonic?
  • accountRS is a new address generated by me? It should be exclusively for the bridge, right?
  1. The JSON file must be configured in the Contract runner, right?

  2. Can I deploy the smart contract in Mumbai separately and then configure only the contractAddress?

  3. The last one (I work with Windows): Do I need to copy the Bitbucket contract files into my folder? (...\Ardor\addons\src\java\com\jelurida\ardor\contracts)

Thank you! :hearts:

  1. The secrets must be random strings, generated with enough bits of entropy. Mnemonics or not - doesn't matter. accountRS - yes, you create a new account, exclusive for the bridge, and provide the address there. You will need the passphrase when you run the contract. Read this if you haven't already: Ardor Asset to ERC-1155 Bridge
  2. Yes, this is one way to go.
  3. You can do it manually but it isn't (at least it wasn't in the past) an easy task especially to provide the parameters. So there is a special command for deployment which you can use: deployEthContract. But beware that it is very possible that the solidity compiler won't work on Win.
  4. You shouldn't be required to copy files manually. I'm not sure where that Ardor root folder is. Git clone the asset-to-erc1155-bridge from bitbucket and init the git submodules. This will download the ardor-library submodule, which is the only ardor library you should need - no need to copy stuff to another Ardor installation.
2 Likes

I can't find a way to make deployEthContract work.

Where should I launch it from?

I try to deploy to my node but I can't see it in "contracts".


How can I check that the Contract runner information is correct? I mean, the data of the AssetsErc1155Peg.json is correctly configured in the contract runner.

I have tried restarting the VPS but it still does not show up.

EDIT: THIS PART IS SOLVED.

On the other hand, for the tokenID mapping configuration, if I have autoMint enabled, I guess I have to "invent" them on Polygon's side.

ASSETArdorXX1 -> P1
ASSETArdorXX2 -> P2

P1 and P2 at the time of configuration do not exist. I imagine it will automatically mine and create the P1 collection when the first NFT is generated, right?


We currently work with the Opensea Smart contract and the tokenIds were known to us (they were pre-generated).

We want to change it to our contract in its entirety.

if you have the eth tokens minted by other means, disable autoMint and use the mapping

ah so you want to switch to auto minted? Then the mapping is not used. The IDs of the auto-minted tokens are generated from the asset id

This contract is from scratch.
I have nothing minted.

I want to do everything from scratch.

Great, that's exactly what I wanted to know.
So I delete everything from "assetIdToErc1155IdMap"?

yes

Do I need to leave it empty?
"assetIdToErc1155IdMap": {}

Or do I delete it completely?


On the other hand... I can't manage to deploy the contract in Mumbai with the deployEthContract command... what can I do?

ah no, deployEthContract is not a gradle task. It's a command which is provided by the Ardor contract

I have also tried calling with:

{
"contract": "AssetsErc1155Peg",
"command": "deployEthContract"
}

But I can't get it to work... Is there anything I need to do first?

You have the Ardor contract running, right? Now call triggerContractByRequest with parameters contractName=AssetsErc1155Peg and setupParams={"command":"deployEthContract"}. It is also a good idea to provide the URI from where services like opensea can download the metadata of your tokens. You can see an example in this section of the tutorial: Ardor Asset to ERC-1155 Bridge

¡Hello!

Now I have this error... from which address is the deployment done?

Error processing transaction request: insufficient funds for gas * price + value",

This is a Solidity message, but I can't figure out from which address are trying to deploy.

I can't get any ETH address, it won't let me execute any command without the contractAddress... but first I have to do deployEthContract.

How can I continue?

Thanks you!!!

The EBA account address (which is generated from ethereumBlockedAccountSecret and which uploads the contract) is printed in the logs. You are right that I must let you get that with API. Sorry, I'll try to fix that today. For now search the logs for "EBA=" or something like that

1 Like

I can't find anything in the logs with "EBA".

In fact, the only ETH address I can find is:

How can I check that this is the address generated for me?

I'm going to try modifying the secret and generate a new one... maybe then I can scan more recent logs.

No, that's something else. OK, I allowed the getPegAddresses to execute when contractAddress is not set. But the changes won't get to bitbucket soon. Here's a patch with the changes

Subject: [PATCH] Allow getting the peg addresses even if initialization fails
---
Index: contract/src/main/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155Peg.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/contract/src/main/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155Peg.java b/contract/src/main/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155Peg.java
--- a/contract/src/main/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155Peg.java	(revision c6f2a118b4f3bbd1295a7712821258029c1cbd9f)
+++ b/contract/src/main/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155Peg.java	(revision 60f5b1221d3daa33cb1aaeffb7543d49b21ff8a6)
@@ -379,6 +379,11 @@
         if (command == null) {
             return context.generateErrorResponse(10001, "Please specify a 'command' parameter");
         }
+        if ("getPegAddresses".equals(command) && pegContext.ethBlockedAccount != null) {
+            response.put("ethereumBlockedAccount", pegContext.ethBlockedAccount.getAddress());
+            response.put("ardorBlockedAccount", context.getAccountRs());
+            return response;
+        }
         if (pegContext.initializationError != null) {
             if (pegContext.initializationError.equals(CONTRACT_ADDRESS_MISSING_ERROR) && DEPLOY_ETH_CONTRACT_COMMAND.equals(command)) {
                 return pegContext.deployEthContract(context,
@@ -389,10 +394,7 @@
                 return context.generateErrorResponse(10004, "Peg initialization error " + pegContext.initializationError);
             }
         }
-        if ("getPegAddresses".equals(command)) {
-            response.put("ethereumBlockedAccount", pegContext.ethBlockedAccount.getAddress());
-            response.put("ardorBlockedAccount", context.getAccountRs());
-        } else if ("getUnwrapDepositAddress".equals(command)) {
+        if ("getUnwrapDepositAddress".equals(command)) {
             String ardorRecipientPublicKey = getArdorRecipientPublicKeyParameter(context, requestParams);
             if (ardorRecipientPublicKey == null) {
                 return context.getResponse();
Index: contract/src/test/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155PegTest.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/contract/src/test/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155PegTest.java b/contract/src/test/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155PegTest.java
--- a/contract/src/test/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155PegTest.java	(revision c6f2a118b4f3bbd1295a7712821258029c1cbd9f)
+++ b/contract/src/test/java/com/jelurida/ardor/contracts/interchain/eth/AssetsErc1155PegTest.java	(revision 60f5b1221d3daa33cb1aaeffb7543d49b21ff8a6)
@@ -437,7 +437,7 @@
         processUnwraps(CHUCK, 0, 0, assetIds.size());
     }
 
-    @Ignore("to save testnet coins")
+    //@Ignore("to save testnet coins")
     @Test
     public void testMinterDeployment() throws Exception {
         APICall.InvocationError error = contractRequest("deployEthContract").build().invokeWithError();
@@ -449,6 +449,9 @@
         paramsJo.put("ethereumBlockedAccountSecret", "poor guy 1234");
         setRunnerConfig(configJo.toJSONString().getBytes());
 
+        JO pegAddresses = contractRequest("getPegAddresses").callNoError();
+        Assert.assertTrue(pegAddresses.isExist("ethereumBlockedAccount"));
+
         error = contractRequest("deployEthContract").build().invokeWithError();
         Assert.assertTrue(error.getErrorDescription().contains("insufficient funds for gas * price + value"));
 
1 Like

It works, now I can continue!

Thank you very much!!!!