Skip to content

Instantly share code, notes, and snippets.

@TechNinjaWeb
Created September 24, 2019 09:42
Show Gist options
  • Save TechNinjaWeb/f7e09635a6214d0969d9a9e0ca270020 to your computer and use it in GitHub Desktop.
Save TechNinjaWeb/f7e09635a6214d0969d9a9e0ca270020 to your computer and use it in GitHub Desktop.
RadixDLT SDK Questions & Example
// Generating ID's from seed for re-use purposes
const myIdentity = getSeededSimpleIdentity('me')
const myAccount = myIdentity.account
const toIdentity = getSeededSimpleIdentity('friend')
const toAccount = toIdentity.account
// TBD: Store RRI
let token;
// Define sample coin
const symbol = 'EXMP'
const name = 'Example Coin'
const description = 'My example coin'
const granularity = 1
const amount = 1000
const iconUrl = 'http://a.b.com/icon.png'
// Step 1: Create the token and store a reference upon success
new RadixTransactionBuilder().createTokenMultiIssuance(
myIdentity.account,
name,
symbol,
description,
granularity,
amount,
iconUrl
).signAndSubmit(myIdentity)
.subscribe({
token = myIdentity.account.tokenDefinitionSystem.getTokenDefinition(symbol) // will return token defintion
})
// Step 2: Add the definition to the list of known tokens
radixTokenManager.addTokenDefinitionSubscription(tokenReference)
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The following methods are tied to button actions
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Mint 10 tokens
RadixTransactionBuilder.createMintAtom(myIdentity.account, tokenReference, 10).signAndSubmit(myIdentity).subscribe({
next: status => {},
complete: () => {
console.log('Tokens have been minted', customToken)
},
error: error => {}
})
// Step 3: Transfer some custom tokens to a friend
// Send 5 tokens to the address
RadixTransactionBuilder
.createTransferAtom(myAccount, toAccount, tokenReference, 10)
.signAndSubmit(myIdentity)
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Reboot the server and redo Steps 1-2
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*************************************************************************************************************
Step 1: Balance = 1000 EXMP
Step 2: After Minting, Balance = 1010 EXMP
Step 3: After Transfer, Balance = 1000 EXMP => Friend has 10 EXMP
-----------------------------------------------------------------------------
Step 4: Reload Server, Token get's re-issued again and new Balance = 1000 EXMP
Step 5: Token get's minted again, new Balance = 1010 EXMP
-----------------------------------------------------------------------------
Step 6: Get Friend's Balance = 10 EXMP
Total EXMP coins in the universe = 1020
Total Issued = 1010
-----------------------------------------------------------------------------
Seems that upon reboot, my friend has 10 EXMP tokens prior to the reissuance.
*************************************************************************************************************
1. what happens when a token is reissued after my dev server reboots,
but the testnet is still loaded?
2. If other tokens exist in the wild and I re-issue my token, how do i make sure the tokens in the wild
cannot be spent?
*************************************************************************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment