Skip to content

Instantly share code, notes, and snippets.

View critesjosh's full-sized avatar
🥸

josh crites critesjosh

🥸
View GitHub Profile
@critesjosh
critesjosh / Relay.sol
Created January 15, 2018 16:23
A relay contract for upgradable contracts
contract Relay {
address public currentVersion;
address public owner;
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_
}
@critesjosh
critesjosh / circuit_breaker.sol
Last active January 15, 2018 16:39
Add pausability to a smart contract
pragma solidity ^0.4.10;
contract Pausable {
bool public stopped = false;
address private owner;
modifier isAdmin() {
if(msg.sender != owner) {
revert();
contract Relay {
address public currentVersion;
address public owner;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function Relay(address initAddr) {
// This will not compile
pragma solidity ^0.4.0;
contract X {}
contract A is X {}
contract C is A, X {}
// This is ok
@critesjosh
critesjosh / EIP20Factory.sol
Created February 22, 2018 16:03
erc20 token factory
// Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.18;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
@critesjosh
critesjosh / SimpleStorage.sol
Last active May 12, 2018 13:53
A simple storage contract
// deployed to the Rinkeby network @ 0x4103e048515a5ebdf34b32ed7692254a16c6d184
pragma solidity ^0.4.0;
contract SimpleStorage {
uint256 storedData;
uint256 public timesSet;
address public lastCaller;
event Updated(uint newValue);
@critesjosh
critesjosh / Greeter.sol
Created May 14, 2018 21:49
Two greeter contracts. One referencing a library, the other not.
pragma solidity ^0.4.0;
contract GreeterA {
string greeting;
uint count;
address[] greeted;
function GreeterA(string _greeting) {
greeting = _greeting;
}
@critesjosh
critesjosh / Unoptimized.sol
Last active May 17, 2018 14:03
An unoptimized solidity contract
pragma solidity ^0.4.0;
contract Unoptimized {
bool oftenTrue = true;
bool oftenFalse = false;
uint loops = 0;
string greeting;
@critesjosh
critesjosh / Optimized.sol
Created May 17, 2018 14:03
Optimizations to the Unoptimized.sol contract
pragma solidity ^0.4.0;
contract Optimized {
bool oftenTrue = true;
bool oftenFalse = false;
uint loops = 0;
bytes32 constant statictext = "Hello world";
3Box is a social profiles network for web3. This post links my 3Box profile to my Github account!
✅ did:muport:Qma2o5oqaVY9hdyNKpdCfGCutgWiotrL9mN3aPWFjnZ8kN ✅
Create your profile today to start building social connection and trust online. https://3box.io/