42

This is a question that I am asked often by developers who assume that a contract has a private key of its own to sign any transactions that it makes.

1 Answer 1

44

Contracts do not possess private keys in the same way that your ether wallet does. Instead, they have programming code written in the language of the Ethereum Virtual Machine.

To determine what a contract "does", all members of the Ethereum network simply run the relevant portion of code every time a transaction or other contract uses the contract's function. Because the code and EVM are carefully defined, everyone will always agree on what the outcome of the operation was. This includes whether or not the contract sent a transaction to any other contract. Because everyone can agree on the origin of the message, no further degree of verification (such as that provided by a signature) is necessary.

2
  • 6
    The above answer is contradictory to this answer for a similar question. What's the deal? This linked answer seems to imply that a contract's public address has a private key in the sense that it's part of a cryptographic key-pair. And if the private key were somehow discovered/cracked, the contract's funds could be extracted. Can someone please explain? Nov 13, 2017 at 22:25
  • 3
    @JonathanTran, it's true that there exists some private key that corresponds the contracts address, it is not actually known by any party including the contract itself. Since the key is not actually stored anywhere, the only way to get it would be to guess. Since guessing a private key is so mathematically improbable as to be impossible, it will never be discovered or cracked, unless the underlying elliptic curve cryptography is also compromised, in which case we have bigger problems.
    – vividn
    Jul 6, 2022 at 10:26

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.