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 / 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 / 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 / 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 / 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 / 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 / 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"
},