Skip to content

Instantly share code, notes, and snippets.

View devonwesley's full-sized avatar
Probably at coffee shop in Oakland, CA.

Devon Wesley devonwesley

Probably at coffee shop in Oakland, CA.
  • Oakland, CA
View GitHub Profile
@devonwesley
devonwesley / reentrancy_attack.js
Created July 16, 2018 10:50
`./geth --preload "/Users/you/here/reentrancy_attack/scripts/scenario.js" attach ipc:newdata/geth.ipc`
var VictimContract = eth.contract([
{
"constant": false,
"inputs": [],
"name": "withdraw",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
@devonwesley
devonwesley / 2_deploy_basic_token.js
Created March 27, 2018 23:02
This a deployment script for our BasicToken contract.
var BasicToken = artifacts.require("./BasicToken.sol");
module.exports = function(deployer, network, accounts) {
deployer.deploy(BasicToken, 10000000000, accounts[0]);
};
@devonwesley
devonwesley / BasicToken.sol
Last active March 27, 2018 05:15
This is a basic token contract provided by the OpenZeppelin team.
pragma solidity ^0.4.18;
contract BasicToken {
mapping(address => uint256) balances;
string public constant NAME = "BasicToken";
string public constant SYMBOL = "BTN";
uint256 totalSupply_;
event Transfer(address indexed from, address indexed to, uint256 value);
function BasicToken (uint256 INITIAL_SUPPLY, address _owner) {
@devonwesley
devonwesley / Self-destructed.sol
Created March 20, 2018 00:48
Simplified WalletLibrary contract.
pragma solidity ^0.4.6;
contract WalletLibrary {
address public owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
@devonwesley
devonwesley / 2_deploy_wallets.js
Last active March 14, 2018 23:56
Deployment script for the Wallet and WalletLibrary contracts.
const WalletLibrary = artifacts.require("./WalletLibrary.sol");
const Wallet = artifacts.require("./Wallet.sol");
module.exports = function(deployer, network, accounts) {
deployer
.deploy(WalletLibrary)
.then(() =>
deployer.deploy(Wallet, WalletLibrary.address, accounts[0])
);
};
@devonwesley
devonwesley / Wallet.sol
Created March 14, 2018 18:54
This is a Wallet contract it interfaces with the WalletLibrary contract to become a fully functioning contract wallet. DO NOT USE.
pragma solidity ^0.4.6;
contract Wallet {
address public owner;
address public _walletLibrary;
function Wallet(address libAddress, address _owner) public {
_walletLibrary = libAddress;
_walletLibrary.delegatecall(bytes4(keccak256("initWallet(address)")), _owner);
}
@devonwesley
devonwesley / WalletLibrary.sol
Last active March 14, 2018 17:51
A mock WalletLibrary that has flaws DO NOT use for you real contract flow.
pragma solidity ^0.4.6;
contract WalletLibrary {
address owner;
function initWallet(address _owner) {
owner = _owner;
}
function changeOwner(address _newOwner) external {
@devonwesley
devonwesley / truffle.js
Created March 14, 2018 00:26
A config file for TruffleJS, this file will tell the TruffleJS tools what blockchain to work with in development.
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
}
}
}
@devonwesley
devonwesley / deploy.md
Created January 12, 2018 02:17
The deployment section of the app.
  1. Install the Ganache Blockchain:
$ npm install --global ganache-cli
  1. Get a Web3 instance:
if (typeof web3 !== 'undefined') {
@devonwesley
devonwesley / compile.md
Last active January 12, 2018 00:27
Compiling contracts in the browser.
  1. Clone the repo:
$ git clone [email protected]:Jusdev89/Remix-Mini-Starter.git
  1. Inside of the mini_remix_stater
$ open index.html