Skip to content

Instantly share code, notes, and snippets.

Probably at coffee shop in Oakland, CA.

Devon Wesley devonwesley

Probably at coffee shop in Oakland, CA.
View GitHub Profile
@devonwesley
devonwesley / reentrancy_attack.js
Created Jul 16, 2018
`./geth --preload "/Users/you/here/reentrancy_attack/scripts/scenario.js" attach ipc:newdata/geth.ipc`
View reentrancy_attack.js
var VictimContract = eth.contract([
{
"constant": false,
"inputs": [],
"name": "withdraw",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
@devonwesley
devonwesley / 2_deploy_basic_token.js
Created Mar 27, 2018
This a deployment script for our BasicToken contract.
View 2_deploy_basic_token.js
var BasicToken = artifacts.require("./BasicToken.sol");
module.exports = function(deployer, network, accounts) {
deployer.deploy(BasicToken, 10000000000, accounts[0]);
};
@devonwesley
devonwesley / BasicToken.sol
Last active Mar 27, 2018
This is a basic token contract provided by the OpenZeppelin team.
View BasicToken.sol
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 Mar 20, 2018
Simplified WalletLibrary contract.
View Self-destructed.sol
pragma solidity ^0.4.6;
contract WalletLibrary {
address public owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
@devonwesley
devonwesley / 2_deploy_wallets.js
Last active Mar 14, 2018
Deployment script for the Wallet and WalletLibrary contracts.
View 2_deploy_wallets.js
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 Mar 14, 2018
This is a Wallet contract it interfaces with the WalletLibrary contract to become a fully functioning contract wallet. DO NOT USE.
View Wallet.sol
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 Mar 14, 2018
A mock WalletLibrary that has flaws DO NOT use for you real contract flow.
View WalletLibrary.sol
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 Mar 14, 2018
A config file for TruffleJS, this file will tell the TruffleJS tools what blockchain to work with in development.
View truffle.js
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 8545,
network_id: "*",
}
}
}
@devonwesley
devonwesley / deploy.md
Created Jan 12, 2018
The deployment section of the app.
View deploy.md
  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 Jan 12, 2018
Compiling contracts in the browser.
View compile.md
  1. Clone the repo:
$ git clone git@github.com:Jusdev89/Remix-Mini-Starter.git
  1. Inside of the mini_remix_stater
$ open index.html
You can’t perform that action at this time.