0

I am new in smart contracts and ethereum development DAPPS. I am just curious to know about blocks when they are created and how a block is different from a transaction and a new block is created. When a deploy a contract its also transaction? When I call function in a smart contract which performs update its also a transaction?

If Yes, So when does the block is created?

Consider the following smart contract.

contract mortal {
    /* Define variable owner of the type address */
    address owner;

    /* This function is executed at initialization and sets the owner of the contract */
    function mortal() { owner = msg.sender; }

    /* Function to recover the funds on the contract */
    function kill() { if (msg.sender == owner) selfdestruct(owner); }
}

contract greeter is mortal {
    /* Define variable greeting of the type string */
    string greeting;

    /* This runs when the contract is executed */
    function greeter(string _greeting) public {
        greeting = _greeting;
    }

    /* Main function */
    function greet() constant returns (string) {
        return greeting;
    }

    function updateGreet(string _greeting) public payable returns(bool) {
        greeting = _greeting;
        return true;
    } 
}

The above code is taken from https://ethereum.org/greeter and modified so that anyone can update greeting string by calling updateGreeting function in the greeter smart contract. So considering this smart contract. Please help me understanding the concept.

  • 1
    You are asking too many questions at once. Moreover, everything you ask is or in the yellow paper (ethereum.github.io/yellowpaper/paper.pdf), or in the solidity documentation. PLease, consider using google before asking this type of questions. – Florian Castelain Jan 22 '18 at 7:13
0

- know about blocks when they are created and how a block is different from a transaction and a new block is created: Page 3, part 4 Blocks, State and Transactions

  • When a deploy a contract its also transaction? Yes
  • When I call function in a smart contract which performs update its also a transaction?

Yes. A function that changes the state of the EVM is a "transaction", it costs gas. A function that does not change the state of the EVM is a "call", it is free.

  • If Yes, So when does the block is created? If this is related to the previous question, then I recommend STRONGLY that you read the documentation about that.

  • Please help me understanding the concept.

What concept? This is just very basic code. Where is the question.

PLEASE, ask one question per post. Moreover, all you asked is basic stuff available in the documentation that you should have read BEFORE comming and asking.

  • 1
    thanks, i will surely read the yellow paper. you opened my eyes – Anand Siddharth Jan 22 '18 at 7:44

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.