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
[ | |
{ | |
"constant": false, | |
"inputs": [ | |
{ | |
"name": "addr", | |
"type": "address" | |
} | |
], | |
"name": "getSnippet", |
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.0; | |
contract Counter { | |
int private count = 0; | |
function incrementCounter() public { | |
count += 1; | |
} | |
function decrementCounter() public { | |
count -= 1; | |
} | |
function getCount() public constant returns (int) { |
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
0x721Bf4E86Cd05bac632A5B2Efa8fB4A9687e0C9E |
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.15; | |
contract MyERCToken { | |
// Create a table so that we can map addresses | |
// to the balances associated with them | |
mapping(address => uint256) balances; | |
// 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; |
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
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; |
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
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 |
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
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 |
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
contract MyERCToken { | |
// Create a table so that we can map addresses | |
// to the balances associated with them | |
mapping(address => uint256) balances; | |
// Owner of this contract | |
address public owner; | |
function balanceOf(address _owner) constant returns (uint256 balance) { | |
// Return the balance for the specific address | |
return balances[_owner]; |
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
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 |
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
// 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); |