---
# System prepended metadata

title: ETH 5/4

---

# ETH 5/4

use remix

https://remix.ethereum.org/#appVersion=0.7.7&optimize=false&version=soljson-v0.6.5+commit.f956cc89.js


```solidity=
pragma solidity >= 0.5.1;

contract Inbox{
    string public message;
    
    constructor(string memory initalMessage) public{
        message = initalMessage;
    }
    
    function setMessage(string  memory newMessage) public{
        message = newMessage;
    }
     
    function getMessage() public view returns (string memory){
        return message;
    }
}
```

![](https://i.imgur.com/KC9r7Gk.png)


![](https://i.imgur.com/JWWE0at.png)


![](https://i.imgur.com/UJ6tYQa.png)

## function

![](https://i.imgur.com/kMnySTp.png)

`view` miner 更快驗證

## array

Dynamic array

byte[10] name :+1: 

uint[10][10] num :-1: 

## struct

```solidity=
struct Mystruct{
    uint a;
    biil b;
}

```

## delete
 >> reset element. not real delete them
 >> 


```solidity=
contract Inbox2{
    string public message;
    uint[5] public myUintArray;
    
    struct Mystruct{
        uint counter;
        bool isSet;
    }
    
    Mystruct public someV;
    
    constructor(string memory initalMessage) public{
        message = initalMessage;
        
        myUintArray[0]=1;
        someV.counter=1;
    }
    
    function increase() public{
        someV.counter++;
    }
}
```

![](https://i.imgur.com/pl6FRCw.png)

## state variable

> state variable > store in bc

such as `string public message;`

> local variable > store in mem


## storage

![](https://i.imgur.com/7RbJcln.jpg)


speed faster while store variable in local
![](https://i.imgur.com/uAILqeZ.png)

![](https://i.imgur.com/OrL3kv7.png)

on bc, [1,2,3] 

copy to local and change to [2,2,3]

![](https://i.imgur.com/pBTRpVz.png)


## calling function 

free, only read

## write function 

need fee


## GAS

gas price, you can set the price and gas limit