1

How to find the address of the owner of a smart contract if it does not have any owner-related description like no address assignment, for instance how to find the owner of the following smart contract?

contract C {
   function pay(uint n, address d){
   d.send(n);
}

Somebody, please guide me.

Zulfi.

2
  • 1
    Do you want to find out whi deployed, or who owns the smart contract? Because those two are not always the same.
    – Sky
    Dec 28, 2022 at 7:07
  • @Sky I want the address for the owner which is initialized in the constructor.
    – zak100
    Dec 29, 2022 at 0:57

1 Answer 1

2

There is no owner in your given contract, literally everyone is the owner as everyone can send the balance to anywhere using pay. If you refer the owner to be the deployer then it's the one who deploy the contract, however deployer is different from owner most of the time. If the contract has source code you can check if it implements Openzeppelin Ownable or some similar patterns. If there is no source code, it will be a bit difficult but still doable by either 1 of the two methods:

  1. Tracing the privilege function call: you can get to the point that there is an address check (e.g. get the full execution trace of the transaction to pay() and analyze it). You probably see the comparison msg.sender and owner in evm bytecode.
  2. Track all existing transactions to the deployed contract on blockchain, the tx call to privilege actions is usually originated from the owner address.
4
  • what is this address? obj = await C.new(); console.log(obj.address); Is obj.address is the address of owner?
    – zak100
    Dec 29, 2022 at 0:58
  • @Sky Is the above owner address?
    – zak100
    Dec 29, 2022 at 1:00
  • 1
    that is the contract address after deployment, it's what you need to send transaction to to interact with the code. E.g. you will send tx stating that you want to call function pay() to the address you got from obj.address
    – minhhn2910
    Dec 29, 2022 at 1:23
  • 1
    To make it clearer, I recommend reading : docs.openzeppelin.com/learn/deploying-and-interacting and all related documents about smart contracts
    – minhhn2910
    Dec 29, 2022 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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