Skip to content

Instantly share code, notes, and snippets.

View CHAOWEICHIU's full-sized avatar
🎯
Focusing

Wayne Chiu CHAOWEICHIU

🎯
Focusing
View GitHub Profile
@CHAOWEICHIU
CHAOWEICHIU / ERC20.sol
Last active January 11, 2019 23:22
ERC20 simple code
pragma solidity ^0.5.0;
contract Token {
string public name = "陳之汗😓";
string public symbol = "SWEAT";
uint256 public totalSupply;
uint8 public decimals = 0;
event Transfer(
address indexed _from,
@CHAOWEICHIU
CHAOWEICHIU / DXNDonation.sol
Last active January 13, 2019 02:43
DXNDonationContract
pragma solidity ^0.5.0;
contract DXNDonationContract {
address payable[] public donationList = [
0x8A1DfD12b5B0D28296a14076D5Da56a97216B929
];
function multiTransfer() public payable {
uint256 amount = msg.value / donationList.length;
@CHAOWEICHIU
CHAOWEICHIU / 01_Invisible_Code.sol
Last active January 22, 2019 21:41
Solidity Smart Contract Vulnerability
// Contract Address: 0x70f9eddb3931491aab1aeafbc1e7f1ca2a012db4
pragma solidity ^0.4.19;
contract HomeyJar {
address public Owner = msg.sender;
function() public payable {}
function GetHoneyFromJar() public payable {
@CHAOWEICHIU
CHAOWEICHIU / 02_Unfair_Equation.sol
Created January 22, 2019 21:39
Solidity Smart Contract Vulnerability
pragma solidity ^0.5.0;
contract MultiplicatorX3 {
address payable public Owner;
constructor() public {
Owner = msg.sender;
}
function withdraw() payable public {
@CHAOWEICHIU
CHAOWEICHIU / 03_Useless_Ownership.sol
Last active January 23, 2019 00:58
Solidity Smart Contract Vulnerability
pragma solidity ^0.5.0;
contract Owned {
address payable public owner;
constructor() public {
owner = msg.sender;
}
modifier onlyOwner{ if (msg.sender != owner) revert(); _; }
}
@CHAOWEICHIU
CHAOWEICHIU / 04_Math_Division.sol
Created January 25, 2019 02:10
Solidity Smart Contract Vulnerability
pragma solidity ^0.5.0;
contract FloatingInSolidity {
address payable public Owner;
constructor() public {
Owner = msg.sender;
}
@CHAOWEICHIU
CHAOWEICHIU / derivation_path.js
Last active January 27, 2019 01:11
BIP39 - mnemonic - demo how derivation path works
const HDWalletProvider = require("truffle-hdwallet-provider")
const mnemonic = 'pretty runway design riot organ cloud skate able tide frozen lunar awesome'
const provider237 = new HDWalletProvider(
mnemonic,
"http://testnet.dexon.org:8545",
0,
1,
true,
"m/44'/237'/0'/0/", /* For DEXON Network */
@CHAOWEICHIU
CHAOWEICHIU / 04_Manipulate_Lottery_Outcome.sol
Created January 27, 2019 23:44
Solidity Smart Contract Vulnerability
pragma solidity ^0.5.0;
contract Lottery {
address[] public losers;
address[] public winnners;
function imaginaryTruelyRandomNumber() public view returns (uint256) {
return block.timestamp;
}
@CHAOWEICHIU
CHAOWEICHIU / rpc.js
Last active January 31, 2019 03:15
The comparison of using RPC call and Web3.js in order to get balance for target wallet address
/*
RPC Call
curl -X POST --data \
'{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x8ECedB018bDdf5bC05C756cA6ED67dbad208CAFf", "latest"],"id":1}' \
http://testnet.dexon.org:8545 \
-H 'Content-Type: application/json'
RPC Response
{"jsonrpc":"2.0","id":1,"result":"0x360b405b6db5ac3000"}
/*
Contract source: https://github.com/dexon-foundation/hello-dexon/blob/master/contracts/Hello.sol
Deployed Contract address: 0xFF24A07D64C2c6E5e3309028828836099968c6A4
Method: get()
curl -X POST --data '{"jsonrpc": "2.0", "method": "eth_call", "params": [{"to": "0xa66dd3a9905a71e67006dfaa0aa82a302f247014", "data": "0x..."}, "latest"], "id": 1 }' http://testnet.dexon.org:8545 -H 'Content-Type: application/json'
*/
const Web3 = require('web3')