I want to know if Ethereum stores the contract's deployer address by default.

I know Ownable Library which stores owner's address in a storage variable. I want to know if Ethereum blockchain stores this address too in deployment transaction. If so, how can i access this information from truffle tests ?

Thanks a lot


The contract's deployer address is stored in a variable called msg.sender. You can simply assign msg.sender to any variable or use it directly.

  • Yes i know what is msg.sender. Let's suppose i do not store this information during constructor. Can i access to contract's owner later by another way ? – Bob5421 Apr 5 at 7:43
  • I'm not sure I understand what you mean, but msg.sender is generally whoever calls the contract, not the deployer. Did I misunderstand you? – Linum Labs Apr 5 at 7:49

When someone deploys a contract on Ethereum (or any EVM-based blockchain) they are making a transaction not entirely unlike a regular transaction between two addresses (just with a lot of extra data). Just like any regular transaction is stored on the blockchain, so is a deployment. The deployer is the "from" address, so to speak.

Getting this address wouldn't be a function in Truffle, though. You'd need to scrape the blockchain using whichever library you use for interacting with the blockchain, though I am not sure exactly how to do this.

More to the point, if you are talking about accessing this data in Truffle tests, you should have an easier option - you will be deploying the contracts inside the test suite, so you should have the address natively available. For example, if you used:

let accounts = await web3.eth.getAccounts();
const deployer = accounts[0];

and used deployer to deploy your contracts in the tests, then you should have the address locally.

Another point worth mentioning: the Ownable contracts from OpenZeppelin do not necessarily store the deployer of the contract in the owner storage variable. While the default is that the deployer is set as the owner at deploy, this can be changed afterwards (that's the point of the changeOwnership and renounceOwnership functions), so we're really talking about two different things when we talk about OpenZeppelin's owner and the data in the actual blockchain, which will always be the deployer.

Hope this helps!


Good question. This is not an exact answer but it might help.

Following is an image from etherscan: enter image description here

In the picture it is showing a transaction named contract creation where from address is specified.

  • That is true but how can i access to this information from a solidity contract or from on offchain javascript file ? – Bob5421 Apr 5 at 10:23
  • I have tried this but you can explore transaction logs, if possible, from web3.js. – Anupam Kumar Apr 5 at 10:26

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.