Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Examples

Omkara edited this page Jun 28, 2018 · 12 revisions

Index

Greeter

/* Hello world contract */
pragma solidity ^0.4.18;
import '../mortal/mortal.sol';

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() public constant returns (string) {
        return greeting;
    }
}

greeter execution interface


Event

pragma solidity ^0.4.19;

contract Eventc {

  event Top(string yolo);

  function event_testing() public {
    emit Top('Hello');
  }
}

event event_notification event_details


Payable

payable

pragma solidity ^0.4.19;

contract Payable {
    mapping(address => uint256) public vault;
    event Deposit(
        address indexed _from,
        uint _value
    );

    function deposit() public payable {
        // Events are emitted using `emit`, followed by
        // the name of the event and the arguments
        // (if any) in parentheses. Any such invocation
        // (even deeply nested) can be detected from
        // the JavaScript API by filtering for `Deposit`.
        vault[msg.sender] = msg.value;
        emit Deposit(msg.sender, msg.value);
    }
}

MintableToken

screenshot from 2018-03-21 20-20-37

pragma solidity ^0.4.19;

import 'https://github.com/OpenZeppelin/zeppelin-solidity/contracts/token/ERC20/MintableToken.sol';

contract GustavoCoin is MintableToken {
    string public name = "GUSTAVO COIN";
    string public symbol = "GUS";
    uint8 public decimals = 18;
}

CryptoKitties

screenshot from 2018-03-21 22-26-50_result screenshot from 2018-03-21 22-26-50

Clone this wiki locally