0

I am not sure if it would show my address or the factory contract's address (or both).

3
  • 1
    What or who is "it" in "it show"? And what do you mean "created in the blockchain"? Where else would it be created??? Commented Jan 30, 2020 at 6:27
  • Plus, I doubt that anything would show you the key (given that one of the basic ideas about private keys is that they should remain secret). Commented Jan 30, 2020 at 6:30
  • I mean public key
    – Andrew
    Commented Jan 30, 2020 at 17:49

3 Answers 3

2

Blockchain contains enough information to find out whether particular contract was deployed by externally owned address or another smart contract. In the latter case one may also find out what externally owned address initiated the transaction. So the answer is: if you've created new smart contract by calling already deployed factory smart contract, then anyone may find out both: your address and factory contract address, having only blockchain data and the address of the contract you've deployed.

While this information is contained in blockchain, it cannot be extracted using Web3 API. You will need to use blockchain explorer, such Etherscan.io, or something like Google BigQuery.

2
  • If I am running a full node, is there an API I can hit in the node to get this data for a given transaction?
    – Andrew
    Commented Jan 30, 2020 at 18:32
  • Do you mean that you already know what transaction the smart contract was deployed within? Because it is not easy to find out this. Commented Jan 30, 2020 at 20:26
2

The transaction which creates the sub-contract will of course originate from your account. The transaction is sent to the factory contract with data to call a function inside the factory contract.

Once the transaction is executed (by a miner) the function execution issues an internal transaction to create the new contract. Here's an example of a contract creating a contract: https://etherscan.io/tx/0x1cb928b1b237252a975719c4a7a26d90fc7bdee7569882b918510aff64fc8686 .

I'm not sure what you mean with your question about the key. No private keys are of course exposed, only public addresses.

2
2

Contracts have no keys, but you will want the address.

There is no automatic way to see what happened other than interpreting the factory code, as all nodes do.

That's a little cruel for front-ends so emit an event in the factory.

MyContract c = new MyContract();
emit LogNewContract(msg.sender, address(c));

That's how you make it easily observable.

Hope it helps.

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