This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 ERC721 { | |
| // ERC20 compatible functions | |
| function name() constant returns (string name); | |
| function symbol() constant returns (string symbol); | |
| function totalSupply() constant returns (uint256 totalSupply); | |
| function balanceOf(address _owner) constant returns (uint balance); | |
| // Functions that define ownership | |
| function ownerOf(uint256 _tokenId) constant returns (address owner); | |
| function approve(address _to, uint256 _tokenId); | |
| function takeOwnership(uint256 _tokenId); |
This file contains hidden or 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.19; | |
| contract ERC721 { | |
| string constant private tokenName = "My ERC721 Token"; | |
| string constant private tokenSymbol = "MET"; | |
| uint256 constant private totalTokens = 1000000; | |
| mapping(address => uint) private balances; | |
| mapping(uint256 => address) private tokenOwners; | |
| mapping(uint256 => bool) private tokenExists; | |
| mapping(address => mapping (address => uint256)) private allowed; | |
| mapping(address => mapping(uint256 => uint256)) private ownerTokens; |