-
Notifications
You must be signed in to change notification settings - Fork 473
Using contract tools package to create FT #2853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
garikbesson
wants to merge
7
commits into
master
Choose a base branch
from
ft-contract-tools-tutorial
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
76a9f29
Init tutorial how to use contract tools package to create FT
garikbesson 6f35fb5
update tutorial
garikbesson 0de2caa
fix code snippets lines
garikbesson 401f855
Merge branch 'master' into ft-contract-tools-tutorial
garikbesson 14a1988
Merge branch 'master' into ft-contract-tools-tutorial
gagdiez f45e3bd
fix: small text corrections
bc6c021
fix: moved contract-tools to the right folder
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,120 @@ | ||||||
| --- | ||||||
| id: ft-contract-tools | ||||||
| title: Create FT using Contract Tools | ||||||
| sidebar_label: Create FT using Contract Tools | ||||||
| description: "Learn how to create a fungible token (FT) using Contract Tools package" | ||||||
| --- | ||||||
|
|
||||||
| import {Github} from "@site/src/components/UI/Codetabs"; | ||||||
| import MovingForwardSupportSection from '@site/src/components/MovingForwardSupportSection'; | ||||||
|
|
||||||
| In this tutorial, we will create a fungible token (FT) using [Contract Tools](https://github.com/near/near-sdk-contract-tools) package. This package is a collection of common tools and patterns in NEAR smart contract development: | ||||||
|
|
||||||
| - Storage fee management. | ||||||
| - Escrow pattern and derive macro. | ||||||
| - Owner pattern and derive macro. | ||||||
| - Pause pattern and derive macro. | ||||||
| - Role-based access control. | ||||||
| - Derive macros for NEP standards: | ||||||
| - NEP-141 (fungible token), extension NEP-148. | ||||||
| - NEP-145 (storage management), and integrations for the fungible token and non-fungible token standards. | ||||||
| - NEP-171 (non-fungible token), extensions NEP-177, NEP-178, NEP-181. | ||||||
| - NEP-297 (events). | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## Introduction | ||||||
|
|
||||||
| The difference of this example from the [FT contract](https://github.com/near-examples/FT) based on `near_contract_standards` package is the approach of using deriving macros to implement NEP standards and common patterns. | ||||||
|
|
||||||
| When we use deriving macros, we can bring `near_contract_standards` implementations into our contract without writing boilerplate code for the each method. That allows us to focus on the unique logic of our contract like minting/burning logic, access control, other custom features. So, this collection of common tools and patterns (mostly in the form of derive macros) is as a sort of OpenZeppelin for NEAR. | ||||||
|
||||||
| When we use deriving macros, we can bring `near_contract_standards` implementations into our contract without writing boilerplate code for the each method. That allows us to focus on the unique logic of our contract like minting/burning logic, access control, other custom features. So, this collection of common tools and patterns (mostly in the form of derive macros) is as a sort of OpenZeppelin for NEAR. | |
| When we use deriving macros, we can bring `near_contract_standards` implementations into our contract without writing boilerplate code for each method. That allows us to focus on the unique logic of our contract like minting/burning logic, access control, other custom features. So, this collection of common tools and patterns (mostly in the form of derive macros) is as a sort of OpenZeppelin for NEAR. |
Outdated
Collaborator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
| To bring basic owner methods to our contract, we derived also `Owner` macro which adds the following methods: | |
| To bring basic owner methods to our contract, we also derived the `Owner` macro which adds the following methods: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should add links to the NEPs for better cross-reference.