Skip to content

Instantly share code, notes, and snippets.

View alexroan's full-sized avatar

Alex Roan alexroan

View GitHub Profile
@alexroan
alexroan / testThrows.sol
Created June 10, 2018 07:15
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
contract TestThrows{
//Assert takes boolean.
//Used in concept of checking data values
function testAssert(){
assert(1==2);
}
//Require takes boolean
//More parameter requirement
function testRequire(){
@alexroan
alexroan / myFirstContract.sol
Last active June 10, 2018 07:24
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.0;
//Interface
interface Regulator{
//Methods to implement
function checkValue(uint amount) returns(bool);
function loan() returns(bool);
}
//Extension of Rregulator interface
contract Bank is Regulator{
@alexroan
alexroan / library.sol
Created June 10, 2018 08:50
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.0;
//keyword library
library IntExtended{
function increment(uint _base) returns(uint){
return _base+1;
}
function decrement(uint _base) returns(uint){
return _base-1;
}
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH.WPINC.'/feed.php');
$feed = fetch_feed('https://www.snippet.uk/groups/not-forgotten/blog/feed/all');
$limit = $feed->get_item_quantity(7); // specify number of items
$items = $feed->get_items(0, $limit); // create an array of items
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';
@alexroan
alexroan / microjournal_entry
Created July 6, 2019 22:31
Microjournal entry shell script.
#!/bin/bash
d=`date +%Y-%m-%d`
filename="$d.md"
echo $1 >> $filename
git add .
git commit -m "$filename"
git push
@alexroan
alexroan / Waterfall.sol
Created February 29, 2020 22:49
Waterfall ponzi scheme smart contract
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract Waterfall {
using SafeMath for uint;
struct User {
address payable addr;
uint amount;
@alexroan
alexroan / Handover.sol
Created March 14, 2020 16:03
Handover Ethereum Smart Contract Ponzi Scheme
pragma solidity ^0.5.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
contract Handover {
using SafeMath for uint;
address payable public owner;
address payable public user;
@alexroan
alexroan / truffle-config.js
Created March 17, 2020 06:25
truffle-smart-contract/truffle-config.js/0.0.2
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "5777",
}
}
}
@alexroan
alexroan / HelloWorld.sol
Last active March 17, 2020 07:46
truffle-smart-contract/HelloWorld.sol/0.0.3
pragma solidity >=0.5.0;
contract HelloWorld {
string private greeting;
constructor() public {
greeting = "Hello World";
}
function getGreeting() public view returns(string memory){
@alexroan
alexroan / 2_deploy_contract.js
Last active March 17, 2020 07:47
truffle-smart-contract/2_deploy_contract.js/0.0.4
const HelloWorld = artifacts.require("HelloWorld");
module.exports = function(deployer) {
deployer.deploy(HelloWorld);
};