Browse Source

feat: added understanding tstandards and examples to tokens page

friedger-patch-7
Patrick Gray 4 years ago
parent
commit
555194bd1f
  1. 15
      src/pages/write-smart-contracts/my-own-nft.md
  2. 48
      src/pages/write-smart-contracts/tokens.md

15
src/pages/write-smart-contracts/my-own-nft.md

@ -31,16 +31,7 @@ By the end of this tutorial, you:
## Prerequisites
## Step 1: understand NFT standard
Similarly to NFT standards in Ethereum (see [EIP 721](https://eips.ethereum.org/EIPS/eip-721)), [SIP009](https://github.com/stacksgov/sips/pull/3) is an interface definition that the Stacks ecosystem aligned on. With support for this standard across wallets and tools, it becomes easy to interact with NFTs. Here are the contract characteristcs are required by the standard:
- Ability to obtain the last token identifier (`get-last-token-id`). This id represents the upper limit of NFTs issued by the contract
- A URI to metadata associated with a specific token identifier. (`get-token-uri`). This URI could resolve to a JSON file with information about the creator, associated media files, descriptions, signatures, and more
- Ability to verify the owner for a given token identifier (`get-owner`). The owner resolves to a [Stacks principal](/write-smart-contracts/principals)
- Ability to transfer an NFT to a recipient (`transfer`). The recipient is required to be a Stacks principal as well
## Step 2: obtain STX for testing
## Step 1: obtain STX for testing
Uploading and calling smart contracts requires you to pay network fees to process the transactions. You need to get some testnet tokens, so you can pay the fees in the next steps.
@ -52,7 +43,7 @@ Once the faucet call was send, you will see a confirmation: "STX coming your way
Once the transaction is successfully processed, you can see that your new balance on the right side of the Sandbox view.
## Step 3: deploy your NFT contract
## Step 2: deploy your NFT contract
Open up the [Sandbox deploy view](https://explorer.stacks.co/sandbox/deploy?chain=testnet). You should see a Clarity code editor with a "hello world" code snippet. Replace the entire code with the following:
@ -115,7 +106,7 @@ With the contract code and name defined, you can hit the "Deploy" button. It wil
Verify that all the information is correct and hit "Confirm" to deploy your contract! You need to wait up to a minute for the transaction to complete.
## Step 4: claim your new NFT
## Step 3: claim your new NFT
// TODO

48
src/pages/write-smart-contracts/tokens.md

@ -11,10 +11,10 @@ images:
A fundamental use of blockchain technology is the representation, store, and transfer of value between users of a
blockchain. Cryptocurrency is a very common use of blockchain technology, and remains one of the primary drivers
of adoption of blockchain technology. Cryptocurrencies are represented by blockchain tokens: representative units
within a given blockchain ecosystem. Blockchain tokens can extend beyond just digital currency, however, and recent
developments throughout the cryptocurrency community have demonstrated potential for the use of blockchain to tokenize
and represent not just money but other tangible assets.
of adoption of blockchain technology. Cryptocurrencies are represented by blockchain tokens: individual units of
value within a given blockchain ecosystem. Blockchain tokens can extend beyond just digital currency, however, and
recent developments throughout the cryptocurrency community have demonstrated potential for the use of blockchain to
tokenize and represent not just money but other tangible assets.
A blockchain token is a digital asset that can be verifiably owned by a user of a blockchain. Blockchain tokens are
governed by a set of rules that are defined by either the blockchain itself (in the case of native tokens) or by a
@ -43,6 +43,28 @@ specifies the standard for fungible tokens on the Stacks blockchain. This specif
that a fungible token on Stacks _must_ have. By complying with this standard, fungible tokens on Stacks can be easily
represented by wallets that support Stacks.
### Understanding the fungible token standard
The [SIP-010][] standard is an interface definition that allows Stacks applications and wallets to interact with
fungible tokens in a standard way. Supporting the standard reduces complexity for token creators to get their tokens
into the ecosystem. Under the [SIP-009][] standard, fungible tokens must have the following characteristics:
- Ability to transfer a specified amount of the token to a recipient (`transfer`). The recipient is required to be a
Stacks principal.
- Ability to obtain the human-readable name of the token (`get-name`).
- Ability to obtain a short name (ticker symbol) for the token (`get-symbol`).
- Ability to get the number of decimals in the token representation (`get-decimals`). This is used to construct a
representation of the token that humans would be familiar dealing with. For example, the US dollar has 2 decimals, if
the base unit is cents.
- Ability to get the balance of the token for a particular Stacks principal (`get-balance-of`).
- Ability to get the total supply of the token (`get-total-supply`).
- A URI to metadata associated with the token (`get-token-uri`). This can resolve to off-chain metadata about the
token or contract, such as an image icon for the token or a description.
### Examples of fungible tokens on Stacks
- [Nothing](https://nothingtoken.com/) ([contract](https://explorer.stacks.co/txid/0x022bed728d648ff1a68036c40f3aff8136ee22fee18380731df0ab9d76d3c4a9?chain=mainnet))
## Non-fungible tokens (NFTs)
Non-fungible tokens (NFTs) are a type of token that are not interchangeable. NFTs have unique traits (usually in the
@ -59,6 +81,24 @@ standard for NFTs on the Stacks blockchain. This specification defines the funct
but most NFTs have more functions or traits attached than those solely described by the specification. By complying with
this standard, non-fungible tokens on Stacks can be easily represented by wallets that support Stacks.
### Understanding the non-fungible token standard
The [SIP-009][] standard is an interface definition that the Stacks ecosystem
aligned on. With support for this standard across wallets and tools, it becomes easy to interact with NFTs. Under the
[SIP-009][] standard, NFT contract must have the following characteristics:
- Ability to obtain the last token identifier (`get-last-token-id`). This id represents the upper limit of NFTs issued
by the contract.
- A URI to metadata associated with a specific token identifier. (`get-token-uri`). This URI could resolve to a JSON
file with information about the creator, associated media files, descriptions, signatures, and more.
- Ability to verify the owner for a given token identifier (`get-owner`). The owner resolves to a
[Stacks principal](/write-smart-contracts/principals).
- Ability to transfer an NFT to a recipient (`transfer`). The recipient is required to be a Stacks principal.
### Examples of NFTs on Stacks
- [This is #1](https://thisisnumberone.com) ([contract](https://explorer.stacks.co/txid/SP3QSAJQ4EA8WXEDSRRKMZZ29NH91VZ6C5X88FGZQ.thisisnumberone-v2?chain=mainnet))
## Further reading
- [The Difference Between Fungible and Non-Fungible Tokens](https://101blockchains.com/fungible-vs-non-fungible-tokens/)

Loading…
Cancel
Save