2

As the contract address is created based on the sender's address plus the nonce value of the transaction creating it, I would think that only the contract owner/creator would know this and could invoke it subsequently to run the code in the contract.

Is it possible to share this address with some other account, so that the other account could invoke the code in the transaction?

Thanks.

N. Mitra
  • 35
  • 3

2 Answers2

1

So long as you have the address, you can interact with whatever contract you want, it's not limited to the creator. Most contracts will limit access to some functions, though

natewelch_
  • 12,021
  • 1
  • 29
  • 43
1

Ethereum contracts by default do not have an owner. The concept of 'contract owner' is not built into the Ethereum protocol. Anyone can call any function they want on any contract.

If you want to restrict access to a function, you will have to do so explicitly in the source code of your contract. For example, a contract with an owner might look like this:

contract Test
{
    address owner;

    // Constructor
    function Test()
    {
        owner = msg.sender;
    }

    // Anyone can call this function
    function a() public
    {
        // Do something...
    }

    // Only the owner can call this function
    function b() public
    {
        require(msg.sender == owner);

        // Do something else...
    }
}
Jesbus
  • 10,478
  • 6
  • 35
  • 62