Token Smart Contract
The code below is an example and requires further refinement for specific business tasks.
Interface BasicStandard is necessary to create a token (implementation is mandatory and provided below).
x
public interface BasicStandard {
String getName();
String getSymbol();
int getDecimal();
boolean setFrozen(boolean frozen);
String totalSupply();
String balanceOf(String owner);
String allowance(String owner, String spender);
boolean transfer(String to, String amount);
boolean transferFrom(String from, String to, String amount);
void approve(String spender, String amount);
boolean burn(String amount);
}
As well as interface ExtensionStandard (Implementation is not mandatory, but recommended and is provided below).
public interface ExtensionStandard extends BasicStandard {
void register();
boolean buyTokens(String amount);
}
Further is the example of a token implementation according to Credits standard.
Examples sets the following in the class constructor:
- Token name (name)
- Token symbol (symbol)
- Number of decimals (decimal)
- Public key of the token owner (owner)
- Total number of tokens (totalCoins)
Examples of implementation of Interfaces BasicStandard and ExtensionsStandard are provided below.
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import ;
import ;
public class Token12 extends SmartContract implements ExtensionStandard { }