Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity 0.5.1; //specifies version of solidity
- contract SimpleCounter {//Doesn't have to match file name
- int counter;// State variable gets stored in a node in Blockchain
- //or: int public counter;
- //public here automatically creates a getter function like the function below
- //initialize variable with constructor
- constructor() public{//Public means anyone can invoke this contract
- counter = 0;
- }
- function getCounter() view public returns (int){//View is like constant keyword. Function does not modify state
- //returns integer
- return counter;
- }
- function increment() public{
- counter += 1;
- }
- function decrement() public{
- counter -= 1;
- }
- //Gas is a unit of computation used to change the state of the contract. Gas translates to ether you
- //need to pay when somene invokes a function
- }
- //Etherum stores the entire state of your program on the Blockchain
- //Smart contracts are programs that you can interact switch
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement