This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict' | |
| const Web3 = require('web3') | |
| const keythereum = require('keythereum') | |
| const Tx = require('ethereumjs-tx') | |
| let web3 = new Web3(new Web3.providers.HttpProvider('http://140.119.164.155:8545')); | |
| // read from key file | |
| let keyObj = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.0; | |
| // THIS CONTRACT CONTAINS A BUG - DO NOT USE | |
| contract Fund { | |
| /// Mapping of ether shares of the contract. | |
| mapping(address => uint) shares; | |
| /// Withdraw your share. | |
| function withdraw() { | |
| if (msg.sender.send(shares[msg.sender])) | |
| shares[msg.sender] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.2; | |
| library Set { | |
| struct Data { mapping(uint => bool) flags; } | |
| function insert(Data storage self, uint value) returns (bool) { | |
| if (self.flags[value]) | |
| return false; // value already there | |
| self.flags[value] = true; | |
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.2; | |
| library Set { | |
| // library 不能真的有狀態變數,但呼叫 library 的合約可以擁有 (請見下方 contract) | |
| struct Data { mapping(uint => bool) flags; } | |
| // 加上 storage 修飾字之後,self 就會指向呼叫 library 的合約的某個狀態變數 | |
| // 此為 library 特有的功能 | |
| function insert(Data storage self, uint value) returns (bool) { | |
| if (self.flags[value]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.0; | |
| contract BuyNccuCoin { | |
| address public minter; | |
| mapping (address => uint) public balances; | |
| event Sent(address from, address to, uint amount); | |
| function BuyNccuCoin() { | |
| minter = msg.sender; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| contract GradesContract { | |
| address public teacher; | |
| mapping (address => Grades) studentGrades; | |
| address[] studentIds; | |
| struct Grades { | |
| uint ChineseGrade; | |
| uint EnglishGrade; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <snippet> | |
| <!-- put this file in /packages/User/<Folder Name>/console_log.sublime-snippet then restart your Sublime Text 2 --> | |
| <content><![CDATA[console.log($1);$0]]></content> | |
| <tabTrigger>conl</tabTrigger> | |
| <scope>text.html,source.js</scope> | |
| <description>console.log()</description> | |
| </snippet> | |
| <snippet> | |
| <!-- put this in another file /packages/User/<Folder Name>/console_dir.sublime-snippet then restart your Sublime Text 2 --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity ^0.4.0; | |
| contract NccuBank { | |
| address public minter; | |
| mapping (address => uint) public balances; | |
| event Sent(address from, address to, uint amount); | |
| function NccuBank() { | |
| minter = msg.sender; |