Skip to content

Instantly share code, notes, and snippets.

@xoriole
Created April 30, 2018 00:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xoriole/f1e5342367b55109d408ed6860a5bdfc to your computer and use it in GitHub Desktop.
Save xoriole/f1e5342367b55109d408ed6860a5bdfc to your computer and use it in GitHub Desktop.
Token example 1 - First Token
pragma solidity ^0.4.12;
contract MyFirstToken {
string public name = "MyFirstToken";
string public symbol = "MFT";
uint8 public decimals = 2;
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
/**
* Constructor. Initializes contract with some initial supply tokens.
*/
function MyFirstToken( uint256 initialSupply) public {
totalSupply = initialSupply * 10 ** uint256(decimals);
balanceOf[msg.sender] = totalSupply;
}
/**
* Transfer tokens.
*/
function transfer(address _to, uint _value) public {
// Prevent transfer to 0x0 address.
require(_to != 0x0);
// Check if the sender has enough
require(balanceOf[msg.sender] >= _value);
// Check for overflows
require(balanceOf[_to] + _value >= balanceOf[_to]);
// Save this for an assertion in the future
uint previousBalances = balanceOf[msg.sender] + balanceOf[_to];
// Subtract from the sender
balanceOf[msg.sender] -= _value;
// Add the same to the recipient
balanceOf[_to] += _value;
// Make sure math is correct. Assertions should never fail
assert(balanceOf[msg.sender] + balanceOf[_to] == previousBalances);
}
}
@creceyganahappy
Copy link

QUIERO MONTAR UN TOKEN EN LA BINANCE SMAR CHANCE PODRIAS AYUDARME SOY UN INFLUENCER Y TENGO UN PROYECTO MEDIO HAMBIOENTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment