This repository was archived by the owner on Jan 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Create ERC style Token
Joshua Primero edited this page Jul 2, 2019
·
4 revisions
In this tutorial, we will build an ERC-like token.
The first step is to create an identity based on public/private keys.
public class CreateToken {
public static void main(String[] args) {
RadixIdentity identity = RadixIdentities.loadOrCreateEncryptedFile("my.key", "password123");
}
}
Next, we initialize the API by using our identity and selecting to bootstrap into the BETANET network.
public class CreateToken {
public static void main(String[] args) {
RadixIdentity identity = RadixIdentities.loadOrCreateEncryptedFile("my.key", "password123");
RadixApplicationAPI api = RadixApplicationAPI.create(Bootstrap.BETANET, identity);
}
}
Every resource on the Radix Ledger is globally identified by a unique RRI. In our case, the token we will create will have an RRI of /<address>/TOKEN.
public class CreateToken {
public static void main(String[] args) {
RadixIdentity identity = RadixIdentities.loadOrCreateEncryptedFile("my.key", "password123");
RadixApplicationAPI api = RadixApplicationAPI.create(Bootstrap.BETANET, identity);
RRI tokenRRI = RRI.of(api.getAddress(), "TOKEN");
}
}
With the RRI we can now create and mint the token on ledger.
public class CreateToken {
public static void main(String[] args) {
RadixIdentity identity = RadixIdentities.loadOrCreateEncryptedFile("my.key", "password123");
RadixApplicationAPI api = RadixApplicationAPI.create(Bootstrap.BETANET, identity);
RRI tokenRRI = RRI.of(api.getAddress(), "TOKEN");
api.createMultiIssuanceToken(tokenRRI, "Cool Token", "The Best Token!").blockUntilComplete();
api.mintTokens(tokenRRI, BigDecimal.valueOf(1000000.00)).blockUntilComplete();
}
}
Congratulations you now have tokens on ledger! You can now send your tokens to any other address:
api.sendTokens(tokenRRI, <to-address>, BigDecimal.valueOf(10.99)).blockUntilComplete();