By factory pattern I mean a contract able to deploy other contracts like in this question: simple bakery factory pattern Each time I trigger
factoryInstance.newContract(args).then(promise);
I get transaction hash after transaction being mined. At this point the newly deployed contract address is already appended to the array inside the Factory contract
address[] public contracts;
Multiple transactions might happen in a short period of time and I want to know, from outside the contract, which one is responsible for a child creation (by its address). But EVM is able to access only the current state of the network (no transaction hashes), and on the front end the transaction receipt is unable to tell which contract has been created by the factory:
contractAddress: null
How do I know which address Y has generated transaction X?
Alternately, is there a way to know which transaction X generated Y? I use ganache-cli and truffle.
Factory
contract is? (Perhaps you can share the relevant code.) Reading between the lines, I assume that it has a function callednewContract
which deploys a new contract and appends its address to an array. Is that right? And you want to find out from outside the contract, for a given contract address, which transaction contained the call tonewContract
that resulted in that contract being created?