0

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

eth
  • 85,679
  • 53
  • 285
  • 406
Andrew
  • 135
  • 1
  • 5

3 Answers3

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.

Lauri Peltonen
  • 29,391
  • 3
  • 20
  • 57
  • I meant public key (I thought that was the same thing as an address? maybe I am confused) – Andrew Jan 30 '20 at 17:50
  • 1
    They're closely related but not the same thing: https://ethereum.stackexchange.com/questions/33171/ethereum-address-vs-public-key – Lauri Peltonen Jan 31 '20 at 06:08
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.

Rob Hitchens
  • 55,151
  • 11
  • 89
  • 145
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.

Mikhail Vladimirov
  • 7,313
  • 1
  • 23
  • 38
  • 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 Jan 30 '20 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. – Mikhail Vladimirov Jan 30 '20 at 20:26