mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-22 09:46:57 +01:00
Update text, small correction
This commit is contained in:
parent
a6b5a7d4e9
commit
6f2ee5fe04
@ -2,7 +2,7 @@
|
||||
layout: guide
|
||||
|
||||
title: "Tutorial: How to launch your own token on BigchainDB"
|
||||
tagline: Learn how to use divisible assets in BigchainDB for token distribution events
|
||||
tagline: Learn how to use divisible assets in BigchainDB for token generating events
|
||||
header: header-token.jpg
|
||||
order: 3
|
||||
|
||||
@ -16,11 +16,11 @@ learn: >
|
||||
|
||||
Hi there! Welcome to our next tutorial about divisible assets. For this tutorial, we assume that you are familiar with the BigchainDB primitives (assets, inputs, outputs, transactions etc.). If you are not, familiarize yourself with the [Key concepts of BigchainDB](../key-concepts-of-bigchaindb/). We also assume that you have completed our [first tutorial](../tutorial-car-telemetry-app/).
|
||||
|
||||
# About token distribution events
|
||||
# About token generating events
|
||||
|
||||
In the last 12 months we have witnessed exponential growth in token distribution events. Many of them have been launched on Ethereum. Since we are experiencing rising interest in potential token launches on BigchainDB, this tutorial aims at showing a very simple approach on how to launch your own token on BigchainDB.
|
||||
In the last 12 months we have witnessed exponential growth in token generating events. Many of them have been launched on Ethereum. Since we are experiencing rising interest in potential token launches on BigchainDB, this tutorial aims at showing a very simple approach on how to launch your own token on BigchainDB.
|
||||
|
||||
This tutorial just aims at illustrating the usage of one building block, namely divisible assets. An actual token launch requires other components which are not discussed here.
|
||||
This tutorial just aims at illustrating the usage of one building block, namely divisible assets. An actual token launch is much more complex and requires other components which are not discussed here. Furthermore, BigchainDB is currently not yet ERC20 compatible.
|
||||
|
||||
{% include_relative _setup.md %}
|
||||
|
||||
@ -67,7 +67,7 @@ function tokenLaunch() {
|
||||
}
|
||||
```
|
||||
|
||||
With these commands, you have minted 10000 tokens. For that give an extra parameter to the `makeOutput()` function. Pay attention to give the function a string instead of a plain number. With the `tokenCreator` keypair you indicate who will be the owner of the tokens. This could for instance be the foundation issuing the tokens. Once this transaction is accepted by BigchainDB, you update the value of the tokens left in the possession of the creator. Right now, all the tokens created are associated with the public key of the creator (`tokenCreater.publicKey`).
|
||||
With these commands, you have minted 10000 tokens. For that, give an extra parameter to the `makeOutput()` function. Pay attention to give the function a string instead of a plain number. With the `tokenCreator` keypair you indicate who will be the owner of the tokens. This could for instance be the foundation issuing the tokens. Once this transaction is accepted by BigchainDB, you update the value of the tokens left in the possession of the creator. Right now, all the tokens created are associated with the public key of the creator (`tokenCreater.publicKey`).
|
||||
|
||||
Now that the tokens have been minted, you can start distributing them to the owners.
|
||||
|
||||
@ -79,15 +79,15 @@ Tokens can be transferred to an unlimited number of participants. In this exampl
|
||||
const amountToSend = 200
|
||||
|
||||
function transferTokens() {
|
||||
// User who will receive of part of the tokens
|
||||
// User who will receive the 200 tokens
|
||||
const newUser = new BigchainDB.Ed25519Keypair()
|
||||
|
||||
// Get outputs of the transactions belonging the token creator.
|
||||
// false argument to retrieve not spent outputs
|
||||
// Search outputs of the transactions belonging the token creator
|
||||
// False argument to retrieve unspent outputs
|
||||
conn.listOutputs(tokenCreator.publicKey, 'false')
|
||||
.then((txs) => {
|
||||
// Just one transaction with outputs not being spent by tokenCreator.
|
||||
// So txs[0]
|
||||
// Just one transaction available with outputs not being spent by tokenCreator
|
||||
// Therefore, txs[0]
|
||||
return conn.getTransaction(txs[0].transaction_id)
|
||||
})
|
||||
.then((tx) => {
|
||||
@ -100,7 +100,7 @@ function transferTokens() {
|
||||
tranferTo: 'john',
|
||||
tokensLeft: tokensLeft
|
||||
},
|
||||
// Output. Two outputs. The hole input must be spent
|
||||
// Transaction output: Two outputs, because the whole input must be spent
|
||||
[BigchainDB.Transaction.makeOutput(
|
||||
BigchainDB.Transaction
|
||||
.makeEd25519Condition(tokenCreator.publicKey),
|
||||
@ -131,7 +131,7 @@ function transferTokens() {
|
||||
}
|
||||
```
|
||||
You have now transferred 200 tokens to the user John. You could repeat the same with multiple other users.
|
||||
With `listOutputs` using `false` as the second argument you retrieved all the outputs, belonging to the user `tokenCreator`, that were not spent yet. There will be just one output that accomplish this characteristics as when you transfer tokens to some other user, you are spending this output and giving the ownership to the other user. Then, you queried for that transaction and made a transfer to John with it. Note however, that there is also a transaction back to `tokenCreator.publicKey`, as you need to 'give back change' due to BigchainDB's transaction model. It is designed in a way that all of the inputs have to be spent in a transaction. That means that if you send part of the `tokensLeft` (200 tokens) to John, you have to send the rest (9800 tokens) back to the `tokenCreator` to preserve that amount.
|
||||
With `listOutputs` using `false` as the second argument you retrieved all the outputs belonging to the user `tokenCreator`, that were not spent yet. There will just be one output that fulfills these characteristics, because when you transfer tokens to another user, you are spending this output and giving the ownership to the other user. Then, you queried for that transaction and made a transfer to John with it. Note however, that there is also a transaction back to `tokenCreator.publicKey`, as you need to 'give back change' due to BigchainDB's transaction model. It is designed in a way that all of the inputs have to be spent in a transaction. That means that if you send part of the `tokensLeft` (200 tokens) to John, you have to send the rest (9800 tokens) back to the `tokenCreator` to preserve that amount.
|
||||
|
||||
Note that in our example, the supply of your tokens was fixed and cannot be changed anymore after creation. So, you would need to clearly define for yourself, how many tokens you will need. However, BigchainDB does offer the option of refillable, divisible assets that allow for a more dynamic token supply. You can learn more about that [here](https://github.com/bigchaindb/bigchaindb/issues/1741).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user