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 / status.html
Created November 8, 2017 19:55
A status bar that helps us keep track of were we're at, in the compiling process.
<div class="mui-container" style="float: left;">
<p id="status" style="float: right; margin-top:20px"></p>
</div>
@devonwesley
devonwesley / compiler_select.html
Last active December 22, 2017 01:17
A way to select solidity compiler versions in a ui.
<section class="mui-container-fluid">
<div class="mui-row">
<div class="mui-col-md-6">
<div class="mui-select">
<select id="versions"></select>
</div>
</div>
</div>
</section>
@devonwesley
devonwesley / compile.html
Last active November 14, 2017 19:27
Code snippet for Web3JS blog
<div class="mui-container-fluid">
<div class="mui-row">
<div class="mui-col-md-6">
<div class="mui-panel">
<p style="font-size:25px; font-weight:bold">
Compile Contract
</p>
<textarea id="source" onclick="this.select()" style="height:360px; width: 600px; display:block; margin-left:20px"></textarea>
<button class="mui-btn mui-btn--primary">
Compile
@devonwesley
devonwesley / HelloWorld.sol
Last active November 20, 2017 23:08
Simple hello world contract for a blog being written.
pragma solidity ^0.4.18;
contract HelloWorld {
function displayMessage() constant returns (string) {
return "Whale hello there!";
}
}
function withdrawShares() insureShareholder {
uint shareCount = shares[msg.sender].shareCount;
shares[msg.sender].shareCount = 0;
if (msg.sender.send(shareCount)){
SharesWithdrawn(msg.sender, shareCount);
} else {
shares[msg.sender].shareCount = shareCount;
FailedSend(msg.sender, shareCount);
}
pragma solidity ^0.4.8;
contract Victim {
bool locked;
/**
@dev Modifier to insure that functions cannot be reentered
during execution. Note there is only one global "locked" var, so
there is a potential to be locked out of all functions that use
the modifier at the same time.
@devonwesley
devonwesley / 2_deploy_contracts.js
Created October 9, 2017 01:05
This is the flow of how we're going to deploy our contracts for our reentrancy attack demonstration.
const Victim = artifacts.require('./Victim.sol')
const Attacker = artifacts.require('./Attacker.sol')
module.exports = function(deployer) {
deployer
.deploy(Victim)
.then(() =>
deployer.deploy(Attacker, Victim.address)
)
}
@devonwesley
devonwesley / Attacker.sol
Created October 8, 2017 21:14
This is an "Attacker"s smart contract that drains the balance of a "Victim"s contract that it calls recursively.
pragma solidity ^0.4.8;
import './Victim.sol';
contract Attacker {
Victim v;
uint public count;
event LogFallback(uint c, uint balance);
@devonwesley
devonwesley / Victim.sol
Created October 8, 2017 21:02
A Ethereum contract with the "Reentrancy" vulnerability (DO NOT DEPLOY, for demonstration only).
pragma solidity ^0.4.8;
contract Victim {
function withdraw() {
uint transferAmt = 1 ether;
if (!msg.sender.call.value(transferAmt)()) throw;
}
function deposit() payable {}
@devonwesley
devonwesley / gist:5ebc063fa95135d195af5e6ff2a4f047
Created August 13, 2017 07:22
jusdev89_ethereum_address_wallet
0x1418191f236A1ADdAC71848f09461593415084d9