Understanding Tokens
Tokens are digital currencies created using Ethereum's smart contract technology. By writing smart contract code, developers can design new cryptocurrencies with customizable features.
Core Capabilities
Basic Functions:
- Create a digital currency with configurable parameters (name, total supply, icon)
- Enable token transfers between users
Advanced Features:
- Implement administrative controls for contract management
- Create whitelist/blacklist systems for account freezing
- Enable token minting (inflation control)
- Design mining reward mechanisms
- Establish automated token exchange systems
- Develop gas fee automation for ETH-less users
Implementing Basic Token Functions
Here's a simplified smart contract for token creation and transfers:
contract MyToken {
mapping (address => uint256) public balanceOf;
string public name;
string public symbol;
uint8 public decimals;
event Transfer(address indexed from, address indexed to, uint256 value);
function MyToken(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) {
balanceOf[msg.sender] = initialSupply;
name = tokenName;
symbol = tokenSymbol;
decimals = decimalUnits;
}
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value || balanceOf[_to] + _value < balanceOf[_to]) throw;
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
}
Deployment via Mist Wallet
- Navigate to "CONTRACTS" > "DEPLOY NEW CONTRACT"
- Paste contract code
- Select "MyToken" from dropdown
Configure parameters:
- Initial supply (token quantity)
- Token name
- Decimal units
- Token symbol
- Click "DEPLOY"
👉 Learn more about Ethereum wallet deployment
Advanced Function Implementation
Enhanced contract with administrative controls:
contract owned {
address public owner;
function owned() { owner = msg.sender; }
modifier onlyOwner { if (msg.sender != owner) throw; _ }
function transferOwnership(address newOwner) onlyOwner { owner = newOwner; }
}
contract MyToken is owned {
string public standard = 'Token 0.1';
string public name;
string public symbol;
uint8 public decimals;
uint256 public totalSupply;
mapping (address => uint256) public balanceOf;
mapping (address => bool) public frozenAccount;
event Transfer(address indexed from, address indexed to, uint256 value);
event FrozenFunds(address target, bool frozen);
function MyToken(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol, address centralMinter) {
if(centralMinter != 0 ) owner = msg.sender;
balanceOf[msg.sender] = initialSupply;
totalSupply = initialSupply;
name = tokenName;
symbol = tokenSymbol;
decimals = decimalUnits;
}
function transfer(address _to, uint256 _value) {
if (frozenAccount[msg.sender]) throw;
if (balanceOf[msg.sender] < _value) throw;
if (balanceOf[_to] + _value < balanceOf[_to]) throw;
if(msg.sender.balance < minBalanceForAccounts) throw;
balanceOf[msg.sender] -= _value;
balanceOf[_to] += _value;
Transfer(msg.sender, _to, _value);
}
}
Key Features Added:
- Contract ownership system
- Account freezing capability
- Minimum balance requirements
- Enhanced error checking
👉 Discover advanced token economics
FAQ Section
Q: What's the minimum ETH needed to deploy a token?
A: Gas costs vary by network conditions, but testnets allow free deployment with test ETH.
Q: Can token contracts be modified after deployment?
A: No - deployed contracts are immutable by design. Always test thoroughly on testnets first.
Q: How do users view their token balances?
A: Through wallet interfaces by watching the token contract address.
Q: What's the practical use of token minting?
A: It enables controlled inflation for reward systems or ecosystem growth.
Q: Is coding experience required to create tokens?
A: Basic programming knowledge helps, but many templates exist for simple implementations.
Q: How are token transaction fees determined?
A: Fees are paid in ETH (gas) and vary by network demand, not token value.