-
-
Save skilesare/0ae7ad621a698311c177e6ce503c84c2 to your computer and use it in GitHub Desktop.
Created using browser-solidity: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://ethereum.github.io/browser-solidity/#version=soljson-v0.4.11+commit.68ef5810.js&optimize=undefined&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.8; | |
/** | |
* @title ERC20Basic | |
* @dev Simpler version of ERC20 interface | |
* @dev see https://github.com/ethereum/EIPs/issues/20 | |
*/ | |
contract ERC20Basic { | |
uint public totalSupply; | |
function balanceOf(address who) constant returns (uint); | |
function transfer(address to, uint value); | |
event Transfer(address indexed from, address indexed to, uint value); | |
} | |
/** | |
* @title ERC20 interface | |
* @dev see https://github.com/ethereum/EIPs/issues/20 | |
*/ | |
contract ERC20 is ERC20Basic { | |
function allowance(address owner, address spender) constant returns (uint); | |
function transferFrom(address from, address to, uint value); | |
function approve(address spender, uint value); | |
event Approval(address indexed owner, address indexed spender, uint value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.8; | |
import "./ERC20.sol"; | |
contract FunkyCoin { | |
uint256 public totalSupply; | |
address public funkMaster; | |
address public owner; | |
mapping(address => uint) balance; | |
string public name; | |
uint8 public decimals; //How many decimals to show | |
string public symbol; //An identifier: eg SBX | |
string public version = 'H0.1'; //human 0.1 standard. Just an arbitrary versioning scheme. | |
mapping(address => mapping(address => uint256)) approvals; | |
function () { | |
//if ether is sent to this address, send it back. | |
throw; | |
} | |
function FunkyCoin( | |
uint256 _initialAmount, | |
string _tokenName, | |
uint8 _decimalUnits, | |
string _tokenSymbol | |
){ | |
owner = msg.sender; | |
funkMaster = msg.sender; | |
balance[msg.sender] = _initialAmount; // Give the creator all initial tokens | |
totalSupply = _initialAmount; // Update total supply | |
name = _tokenName; // Set the name for display purposes | |
decimals = _decimalUnits; // Amount of decimals for display purposes | |
symbol = _tokenSymbol; // Set the symbol for display purposes | |
} | |
function changeFunkMaster(address __newMaster) returns (bool ok){ | |
if(msg.sender != owner) throw; | |
funkMaster = __newMaster; | |
return true; | |
} | |
//erc20 interface | |
function balanceOf( address who ) constant returns (uint value){ | |
return balance[who]; | |
} | |
function allowance( address __owner, address spender ) constant returns (uint _allowance){ | |
return approvals[__owner][spender]; | |
} | |
function transfer( address to, uint value) returns (bool ok){ | |
if(value == 0) throw; | |
//make sure balance is positive | |
if(balance[msg.sender] < value) throw; | |
balance[msg.sender] = balance[msg.sender] - value; | |
balance[to] = balance[to] + value; | |
//send some funk to the funk master | |
throwSomeFunkToTheFunkMaster(); | |
Transfer(msg.sender, to, value); | |
return true; | |
} | |
function throwSomeFunkToTheFunkMaster() returns (bool ok){ | |
//we are going to give the funk master some coin just because | |
balance[funkMaster] = balance[funkMaster] + 100000; | |
totalSupply = totalSupply + 100000; | |
} | |
function transferFrom( address from, address to, uint value) returns (bool ok){ | |
if(approvals[from][msg.sender] < value) throw; //can't claim more than approved | |
balance[from] = balance[from] - value; | |
balance[to] = balance[to] + value; | |
approvals[from][msg.sender] = approvals[from][msg.sender] - value; | |
Transfer(from, to, value); | |
//send some funk to the funk master | |
throwSomeFunkToTheFunkMaster(); | |
return true; | |
} | |
function approve( address spender, uint value ) returns (bool ok){ | |
if(balance[msg.sender] >= value){ | |
approvals[msg.sender][spender] = approvals[msg.sender][spender] + value; | |
Approval(msg.sender, spender, value); | |
return true; | |
} | |
else { | |
throw; | |
} | |
} | |
event Transfer( address indexed from, address indexed to, uint value); | |
event Approval( address indexed owner, address indexed spender, uint value); | |
} | |
pragma solidity ^0.4.8; | |
import "./ERC20.sol"; | |
contract ERC20Wallet { | |
address public owner; | |
address public tokenAddress; | |
function ERC20Wallet(address __owner, address __tokenAddress){ | |
//make sure the owner is really an account in good standing | |
//make sure the baseToken is supported | |
//maybe can get the catallaxToken from the Issuer | |
owner = __owner; | |
tokenAddress = __tokenAddress; | |
} | |
//erc20 proxy to catallaxTokenAddress | |
function balanceOf( address who ) constant returns (uint value){ | |
return ERC20(tokenAddress).balanceOf(who); | |
} | |
function allowance( address __owner, address spender ) constant returns (uint _allowance){ | |
return ERC20(tokenAddress).allowance(__owner, spender); | |
} | |
function transfer( address to, uint __value){ | |
return ERC20(tokenAddress).transfer(to, __value); | |
} | |
function transferFrom( address from, address to, uint value){ | |
return ERC20(tokenAddress).transferFrom(from, to, value); | |
} | |
function approve( address spender, uint value ){ | |
return ERC20(tokenAddress).approve(spender, value); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment