I have a web3J application that is supposed to deploy a contract (by calling a function on another contract) then listen for the contractCreatedEvent that is fired by the factoryContract and then call a function on the new contract.
ContractA = Factory Contract that deploys ContractB and sends EVENT ContractB = Some Contract with function fuBar()
So I do the following:
ContractA.deploy() Address contractB = event.address ContractB.at(contractB).fuBar()
Now my problem is, that both, the
deploy as well as the
fuBar transaction are mined in the same block and fuBar even has a higher position thus not executing a call on the new contract but rather on an address with no code (yet)
can someone explain what is happening here? why do i get the address/event before the contract is actually deployed and operable?