Skip to content

Instantly share code, notes, and snippets.

View aunyks's full-sized avatar
Increasing potential

Gerald Nash aunyks

Increasing potential
View GitHub Profile
// Grabbed from: https://github.com/ethereum/EIPs/issues/20
contract ERC20 {
function totalSupply() constant returns (uint theTotalSupply);
function balanceOf(address _owner) constant returns (uint balance);
function transfer(address _to, uint _value) returns (bool success);
function transferFrom(address _from, address _to, uint _value) returns (bool success);
function approve(address _spender, uint _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint remaining);
event Transfer(address indexed _from, address indexed _to, uint _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
contract MyERCToken {
// In this case, the total supply
// of MyERCToken is fixed, but
// it can very much be changed
uint256 _totalSupply = 1000000;
function totalSupply() constant returns (uint256 theTotalSupply) {
// Because our function signature
// states that the returning variable
// is "theTotalSupply", we'll just set that variable
contract MyERCToken {
mapping(address => uint256) balances;
// Note: This function returns a boolean value
// indicating whether the transfer was successful
function transfer(address _to, uint256 _amount) returns (bool success) {
// If the sender has sufficient funds to send
// and the amount is not zero, then send to
// the given address
if (balances[msg.sender] >= _amount
contract MyERCToken {
// Create a table so that we can map
// the addresses of contract owners to
// those who are allowed to utilize the owner's contract
mapping(address => mapping (address => uint256)) allowed;
function approve(address _spender, uint256 _amount) returns (bool success) {
allowed[msg.sender][_spender] = _amount;
// Fire the event "Approval" to execute any logic
// that was listening to it
0x721Bf4E86Cd05bac632A5B2Efa8fB4A9687e0C9E
@aunyks
aunyks / snipbin-contract-abi.json
Created December 15, 2017 03:25
The Application Binary Interface (ABI) for Snipbin's underlying smart contract. Contract address on ETH mainnet: 0x7dB065361C2956b9bC21d5199F7c7010e6Dc964D.
[
{
"constant": false,
"inputs": [
{
"name": "addr",
"type": "address"
}
],
"name": "getSnippet",
contract MyERCToken {
mapping(address => uint256) balances;
function transferFrom(address _from, address _to, uint256 _amount) returns (bool success) {
if (balances[_from] >= _amount
&& allowed[_from][msg.sender] >= _amount
&& _amount > 0
&& balances[_to] + _amount > balances[_to]) {
balances[_from] -= _amount;
balances[_to] += _amount;

Keybase proof

I hereby claim:

  • I am aunyks on github.
  • I am aunyks (https://keybase.io/aunyks) on keybase.
  • I have a public key ASAWNctls7QnuFFYVuFN75adE6m5sj8EFb5B0OfVMb2Fngo

To claim this, I am signing this object:

@aunyks
aunyks / utils.py
Last active May 2, 2018 21:03
Simple utility functions used throughout my research.
import datetime
import json
import requests
def unix_to_date(unix_int):
if type(unix_int) == type(''):
return datetime.datetime.fromtimestamp(int(unix_int)).strftime('%Y-%m-%d %H:%M:%S')
elif type(unix_int) == type(0):
return datetime.datetime.fromtimestamp(unix_int).strftime('%Y-%m-%d %H:%M:%S')
else:
def to_bin(n):
return bin(n)[2:] if n >= 0 else bin(n)[3:]
def to_int(b):
return int(b, 2)
def ones_complement(b):
return b.replace('1', '2').replace('0', '1').replace('2', '0')
def twos_complement(b):