0

I am completely new to Ethereum. I read a lot of articles and have a question. As far as I understood, one can develop smart contracts in Ethereum that are like executable programs. In these programs one can make a transaction.

For example I want to send 5 Ether to Bob. This is a transaction. Now, I am going to develop a program that compiles on EVM and in this program I send 5 Ether to Bob.

Now my question: I can code anything I want. If I have only 5 Ether in my balance, but I am going to spend 500 Ether to Bob, who will read and check my code and decide how many Ether I can spend or not ? In Bitcoin nodes or miner can check the blockchain and look, how many Bitcoin you have spent and you still have.

1 Answer 1

2

The nodes in Ethereum perform that same function as you mentioned in bitcoin (validating transactions). The code of the smart contracts and their state is stored in the blockchain (just like the transaction outputs are stored in Bitcoin's blockchain).

When a smart contract call is executed, the Ethereum nodes validate that the transaction happens exactly according to the logic of the smart contract. If any node tries to cheat the logic that is stored in the blockchain, then it will be rejected by the rest of the network (just like bitcoin nodes do checks to make sure you have enough balance).

Of course if you write bad logic in your smart contracts, then there can be issues. But with ethereum 'code is law'. If the code says it can be done, it can be done; if the code says it can't be done, it can't be done.

12
  • So when I write a smart contract, other nodes can see my code ?
    – Blnpwr
    Aug 15, 2018 at 9:40
  • Yes, your code is compiled and stored in the blockchain.
    – JasoonS
    Aug 15, 2018 at 9:41
  • Ok, thank you. So in Bitcoin you can make a transaction, but in Ethereum, you can make a transaction only by programming a smart contract that contains the transaction?
    – Blnpwr
    Aug 15, 2018 at 9:42
  • There are projects like 'Enigma', 'TrueBit' and 'Golem' (and some others even), where the code you write isn't stored and executed on the blockchain directly. These projects are doing this for scalabbility or privacy reasons.
    – JasoonS
    Aug 15, 2018 at 9:42
  • I see, thank you, can you please have a look at my 3 rd commenct regarding to transactions?
    – Blnpwr
    Aug 15, 2018 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.