6

I want to prove that a contract was deployed by a specific address (a factory contract). I have noticed that block explorers such as https://etherscan.io/ list the contract creator. How do they get this information? I cant find any way of getting a contracts creators address from the the etherscan api.

How can I identify the address that deployed a contract?

  • The accepted answer is incorrect. The first incoming transaction to a smart contract address is not the creation transaction. The creation transaction is sent to address '0x0'. The receipt of that transaction has contractAddress set to the address of the new smart contract. The first transaction can't have happened until after it's creation. To find the creator, one must look for the creation transaction, which is the transaction with receipt.contractAddress == address. The accepted answer should be de-selected. – Thomas Jay Rush Oct 30 '17 at 11:55
  • @ThomasJayRush can you write an answer so i can accept that one instead? – Joe Nov 1 '17 at 20:24
  • Done. I tried to explain both cases--third-party API and directly from the node. – Thomas Jay Rush Nov 1 '17 at 22:54
  • this question still has no answer. Apparently , it is not possible to get the owner by some javascript/rpc call, apparently, you have to scan all the transactions to find out who the owner is. – Nulik Mar 12 '18 at 1:48
3

If possible, save the users, transactions and contracts as you send them. This way you don't have to look for them later.

If that's not an option, the long route is to find all the transactions related to the contract address. The first incoming one should be the contract creation transaction, the sender of which is the creator.

  • Comments are not for extended discussion; this conversation has been moved to chat. – Waqar Lim Mar 9 '17 at 21:46
3

If you understand how etherscan works you'll be able to do what you are asking.

See : How does Etherscan work?

What etherscan do is reverse of what you are trying to. ie you are trying to get the creator of a contract from an address. Etherscan index the entire blockchain and create relationships between blocks, transactions and accounts.

Etherscan see a block and index all the transactions first, then associate the creation of contracts with the accounts that sent the transactions.


I presuming you are asking for a native geth/web3/etc method that would give you a contract creators address. If so I am not aware of any such method.

1

Otherwise more specifically you can use an attribute in your contract that will store the creator. This attribute can be read by any contract or dapp.

Example:

pragma solidity ^0.4.8;
contract myContract  {

    address public creator;

    function myContract() {
        creator = msg.sender;
    }
}
  • The issue with this is someone could make a similar contract to mine except it defines creator as my address instead of msg.sender. This would look identical to a contract made by me wouldnt it? – Joe Mar 8 '17 at 13:21
  • In that case, instead of checking the creator. You could simply try to share a secret between the factory and the contract. For a given contract, if the factory doesn't know the secret (in a map for example), it can't be trusted. – Greg Jeanmart Mar 8 '17 at 13:34
  • Im not entirely sure what type of secret you mean. I considered using signing but contracts dont have private addresses – Joe Mar 8 '17 at 13:39
1

If you use Etherscan or some other third party blockchain scraper, then chances are the first transaction returned by their API will be the contract creation transaction. You'll be able to tell because the first transaction in the list will have been sent to address 0x0. I'm pretty sure this is how Etherscan works. I'm not sure about other blockchain scrapers. It will be obvious because the transaction will have a to value of 0x0 and the bytecode in the input data field.

If you're looking for a solution that reads directly from the blockchain (i.e. a locally running node), then the only way to find a contract's creation transaction (if you don't know the deploying account) is to scan the chain looking for the address of the contract you're interested in. Look in the transaction receipt's contractAddress data field. Any particular contract address will only ever appear once in a single transaction's receipt. And that transaction will be the transaction in which the contract was deployed.

If you’re lucky you will have written a “contractCreated” event in your deploying smart contract. You won’t be able to get the address during the transaction, but the event will tell you which transaction it is.

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.