Say I have control of addresses A and B, and I am writing contract C. When I deploy C on the blockchain, it will have it's own address, that can send and receive ether. But I want to have a method on C which, when called, sends ether from address A to address B, not to or from C.

Of course I could do this by storing the private key for A in C, but then anyone could look at C, copy the key out, and use it themselves. I want to allow only C to send ether from A, not anyone else.

Is there any way to allow a contract to control another address, without making the key for that address publicly accessible?

3 Answers 3


If A is a contract, then yes. If it is not, your reasoning is correct in that C in this situation would need the private key for A and that will be accessible to anyone who runs an Ethereum client or can read directly form the Ethereum blockchain.

If A is a contract, you can make a check in A such that only C is allowed to initiate a transfer of ether from A to B.

It could look like this in A:

if (msg.sender != "0xb7cB1C96dB6B22b0D3d9536E0108d062BD488F74"){
    return false;
/// Code to transfer ether

You can do this by simply hard coding C's address into the contract A and then compare C's address with msg.sender which returns the caller's address.

Since Ethereum addresses are deterministic, based upon the creator address and its nonce, you can even hard code and deploy A before you have deployed C.

  • 2
    This question has been voted down. It would be nice if the downvoters could leave a comment as to why they consider the answer bad. Commented Mar 15, 2018 at 7:45

No, you can't do this unless A is a smart contract.


Yes, you can do that. Here are the steps.

  1. Create a smart contract A which allows only C to withdraw ether and send to any address.
  2. Deploy an instance of A from inside of C. This will make C as the msg.sender for A.
  3. This will create an address for A and there will be no private key available to access A.
  4. The only one who can withdraw ethers from A would be contract C.

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.