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
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];
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
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 {
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;
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;
0x721Bf4E86Cd05bac632A5B2Efa8fB4A9687e0C9E
@aunyks
aunyks / counter.sol
Last active March 10, 2023 10:33
A simple counter written in Solidity, for Ethereum.
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) {
@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 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);
@aunyks
aunyks / erc721-example.sol
Last active April 12, 2024 00:56
My implementation of the ERC721 token standard. WARNING: THIS CODE IS FOR EDUCATIONAL PURPOSES. DO NOT DEPLOY TO THE NETWORK.
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;