1

I am new to Smart Contracts. When I saw some example of Smart Contracts, I realize that they are just some piece of code, not exactly contracts.

For example function sendCoin(address receiver, uint amount) is a method defined in smart contract which takes receiver address and amount to send Coins to receiver.

But the contract is not about how to send coins, but how much to send. For Example, if the material is delivered on time, make full payment else charge penalty of 10% for every week's delay.

As per my understanding, the invocation - where these if-then rules are written (Representing contract) - is outside smart contract.

Is my understanding correct? Is the term 'Smart Contract' misleading?

Are real contracts are still coded outside the block-chain in application triggering these functions? If yes, then why smart contracts can't be manipulated, the applications can still compromise the contract - For Example. by not paying as per contract terms.

  • what is that a signed piece of paper can do that a signed piece of software can't? and what is that a signed piece of software can do that a signed piece of paper cannot? – cAos May 13 '18 at 15:19
  • @siid: I agree partially as the invocation of contract is outside via some API like web3 or so. Though the piece of code is not compromised but its input parameter can be compromised, if they are not part of ethereum and defined beforehand at the time of contract writing itself. May be I will rephrase my question: "Are the smart contract invocation rules (If-Then rules) are also part of ethereum or can be made part of ethereum?" – Abhinav May 14 '18 at 11:20
1

I think the word contract come from the contract programming. Is a way to design software meeting the requirement of this paradigm. Indeed Solidity supports contract programming natively.

pragma solidity ^0.4.0;

contract Sharer {
    function sendHalf(address addr) public payable returns (uint balance) {
        require(msg.value % 2 == 0); // Only allow even numbers
        uint balanceBeforeTransfer = this.balance;
        addr.transfer(msg.value / 2);
        // Since transfer throws an exception on failure and
        // cannot call back here, there should be no way for us to
        // still have half of the money.
        assert(this.balance == balanceBeforeTransfer - msg.value / 2);
        return this.balance;
    } 
}

given this example as you can see the requires are the pre-conditions while assets are the post-conditions. The side effects are exceptions that will revert the status in the EVM.

enter image description here

  • Thanks for the explanation. But how is the code being triggered? As far as I understand, some-one will use web3 or similar API to invoke the code with some 'address' and 'value'. Surely only half of value will be transferred, as per the implementation. But technically, determining the exact value for 'value' should also be part of contract. Like Send half of 10 to 'mirg', if he answers the question. But with current setup. one can manipulate the value of 'value' and indirectly compromise the contract. – Abhinav May 14 '18 at 11:15
  • so the word object comes from object oriented programming or maybe the opposite, oop has its roots in the way humans perceive reality – cAos May 14 '18 at 12:22
  • @Abhinav how can someone manipulate the 'value'? If so that's a bug. I don't get your point. If your contract has to send always an exact amount of eth then this will be a static value. If the contract has to send half of the value then the code provided is right given is pre-conditions and post-conditions. – mirg May 14 '18 at 14:52
  • 1
    Depends on the type of the contract and the aim of the writer. If one just wants to create a way to transfer value then he will just need to shape the function for transfers. Contract terms can be included in the contract if one wants. That doesn't mean that you won't find scammers trying to fool you. That's is why open source code and a formal language that has only one logical interpretation are more convenient than... – cAos May 14 '18 at 16:46
  • 1
    @Abhinav if your business needs must to meet certain requirements nobody stops you to store the info in the blockchain. eg. you store your product info, the price and so on. When you buy a certain item you just refer to its code and the contract will store the price for it and send to the buyer. Generally, the transfer function you always see in the contracts, its of the ERC20 token standard or some wallets, which have to meet some specifications. – mirg May 15 '18 at 6:05
2

Your understanding is exactly correct. Smart contracts are neither smart, nor contracts. It’s a missleading word.

It’s just software that runs on the EVM. There’s nothing enforcing what they do, other than the fact that the code itself can never be changed.

I think it’s the immutability of the code, and the fact that the code is open source (and therefore agreed to by all parties) that makes people think of them as contracts. You can’t change them once deployed.

  • so what is a contract? – cAos May 13 '18 at 15:16
  • I think of the smart contract as only the thing that runs on the EVM. That is, the part that runs on "Ethereum." I think people call it a contract only because both sides agree to it (because they can both read the source code) and it can't be changed (because code running on the EVM is immutable). There's no legal contract at all. "Contract" is just a poorly chosen word. – Thomas Jay Rush May 13 '18 at 18:09
  • @ThomasJayRush: Thanks! But for me code is just metadata (unless it is not dependent on any outside variable), like what it will do. The actual thing happens, when it is invoked - when the actual parameter is passed. This way of allowing to invoke smart contracts from web3 or other APIs looks little anti to contracts which are already well defined at the time of writing. – Abhinav May 14 '18 at 11:38
  • if the contract is signed by an authority it becomes a legal contract. Even if a contract doesn't have to be signed by a third party when the blockchain assure its immutability and trustiness – cAos May 14 '18 at 12:25

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.