0

I am using truffle with drizzle.

In the contract folder I provide a file that includes two contracts A that is a factory contract and B that is created through one of A's functions

After compiling and migrating, I get two contract files as json: A.json, B.json

The factory contract gets deployed, however when I run my client, I can see in the following error in the console:

Contract B not found on network ID: 5777

and

index.js:1375 uncaught at _callee at _callee 
 at contractsSaga 
 at takeEvery 
 at addContract 
 TypeError: Cannot read property 'contractName' of undefined

When inspecting B.json I see that ABI is provided and contract name is specified in the file.

Question: Should B get deployed to be accessible and if so, how to proceed when I want only A to be able to deploy B and only if a certain function is called? Not mentioning A can deploy multiple Bs.

Thanks

0

Found my mistake. I made false assumption that the B contract must be passed in drizzle options like so:

const options = {
  contracts: [A, B],
  web3: {
    fallback: {
      type: "ws",
      url: "ws://127.0.0.1:9545",
    },
  },
};

Since A contains B, there is no need to specify B in contracts, hence the error:

TypeError: Cannot read property 'B' of undefined

Because A contains B (A is a factory for B) options should be like so:

const options = {
  contracts: [A],
  web3: {
    fallback: {
      type: "ws",
      url: "ws://127.0.0.1:9545",
    },
  },
};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.