0

Are contracts really that different? I guess in theory every contract should have a private key somewhere + it should be possible to send ether to it? Unless geth/parity and other parts of the evm don't have functions specifically checking if every blockchain transfer is wallet vs contract and hence rejecting ether if it's send to contract without payable functions?

1 Answer 1

0

every contract should have a private key somewhere

The private key exists in theory, but since the contract address is not generated by choosing a private key to begin with, the private key of that address remains unknown (and unlikely to be discovered under the current computation limits).

it should be possible to send ether to it

Only if it implements a payable function (this restriction was added at an early stage of the Ethereum blockchain, in order to reduce the amount of unintentional transfers).

checking wallet vs contract

That one is pretty easy, since there is bytecode if and only if the address is that of a contract.

For example, with web3.js v1.2.1, await web3.eth.getCode(address); returns "0x" if and only if there is no bytecode (if and only if address is NOT the address of a contract).

1
  • I see, so almost as I thought...
    – Robert Ggg
    Commented Nov 25, 2019 at 16:17

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.