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.

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

| improve this answer | |
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...
    }
}
| improve this answer | |

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.