1 / 7

Exam 1 Review

This comprehensive exam review covers topics such as blockchain architecture, problem-solving with smart contracts, writing and using modifiers, and designing representations using UML diagrams. Get ready to ace your Solidity exam!

crumb
Download Presentation

Exam 1 Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exam 1 Review

  2. Reading material and topics • Chapter 1, 2,3, • Chapter 4 only up to smart contract • Class notes • Solidity Read the Docs • Topics: • Blockchain architecture; structure, stack and operations • Problem solving : write a SC • Problem solving: write and use modifiers 4. Problem solving: design representation: use case and contract diagram

  3. 1. Blockchainstructure: Dappstack model

  4. 2. Writing an SC • Basic structure of SC • Uint, struct, array, mapping, address data types • Functions syntax ( msg.sender, msg.value etc., simple arithmetic) • Simple if statement, for loop • No modifiers in this question • View function, public function, use of payable

  5. Here is an example pragma solidity ^0.5.2; contract SampleSC{ //data mapping (address=>uint) public donation; uint public deposit; constructor() public payable { deposit = msg.value; donation[msg.sender] = msg.value; } function sendEther() public payable { deposit = address(this).balance; donation[msg.sender] = msg.value; } }

  6. 3. Write and use modifiers, require etc. • Define a modifier • Modifier with messages • Use a modifier • Example from Counter.sol modifier checkIfGreaterThanZero(uint n){ require(value >= n, 'Counter can not become negative.'); _; } Usage: function decrement (uint n) public checkIfGreaterThanZero(n) { value = value - n; }

  7. 4. Design representations: UML diagrams • Use case diagram : plan, requirements • Contract diagram : static design • Sequence diagram : captures dynamics

More Related