Ethereum Contract

Smart Contract

Smart Contract

  • Class Object Instance
  • Not pure function formally
  • Asymmetric Cryptography Signature
  • State Machine

Truffle Suite

  • Framework for building smart contract
  • Interactive console
  • Script migration and deployment
  • Package management

Tested Smart Contract Templates

Access Control

Crowdsales

Tokens

Ownable

Roles

Token Emission

Validation

ERC20 - Amount

ERC721 - Each ID

Create a ERC20 Contract

npm i -g truffle

truffle install zeppelin
pragma solidity ^0.4.23;

import "zeppelin/contracts/token/StandardToken.sol";

contract RytassCoin is StandardToken {
  string public name = "RytassCoin";
  string public symbol = "RYC";

  uint public decimals = 8;
  uint public INITIAL_SUPPLY = 100000000;

  function RytassCoin() public {
    totalSupply = INITIAL_SUPPLY;

    balances[msg.sender] = INITIAL_SUPPLY;
  }
}
pragma solidity ^0.4.11;

contract StandardToken is ERC20, BasicToken {

  mapping (address => mapping (address => uint256)) allowed;

  function transferFrom(address _from, address _to, uint256 _value) public returns (bool)

  function approve(address _spender, uint256 _value) public returns (bool)

  function allowance(address _owner, address _spender) public constant returns (uint256 remaining)

  function increaseApproval (address _spender, uint _addedValue) returns (bool success) 

  function decreaseApproval (address _spender, uint _subtractedValue) returns (bool success) 
}

contract ERC20 is ERC20Basic {
  function allowance(address owner, address spender) public constant returns (uint256);
  function transferFrom(address from, address to, uint256 value) public returns (bool);
  function approve(address spender, uint256 value) public returns (bool);
  event Approval(address indexed owner, address indexed spender, uint256 value);
}

contract ERC20Basic {
  uint256 public totalSupply;
  function balanceOf(address who) public constant returns (uint256);
  function transfer(address to, uint256 value) public returns (bool);
  event Transfer(address indexed from, address indexed to, uint256 value);
}

StandardToken.sol

const RytassCoin = artifacts.require('./RytassCoin.sol');

module.exports = function(deployer) {
  deployer.deploy(RytassCoin);
};

Deployment

truffle develop

> compile

> migrate

Ropsten

Ethereum Smart Contract

By Chia Yu Pai

Ethereum Smart Contract

  • 415