-
Notifications
You must be signed in to change notification settings - Fork 4
fix map key errors and add interaction guide. #7
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
Draft
sarvalabs-akashpaul
wants to merge
1
commit into
main
Choose a base branch
from
0.5.2-update
base: main
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.
Draft
Changes from all commits
Commits
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
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
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,85 @@ | ||
# NFT Contract Interaction Guide | ||
|
||
- Start API server ``logiclab start -d ~/.coco/lab`` | ||
- ```cd ERC721/``` | ||
- ```coco lab start``` Cocolab REPL start | ||
- ```compile NFT``` | ||
- ```get NFT``` lists alll endpoints | ||
- ```register username``` | ||
- ```set default.sender username``` | ||
|
||
## 1. Deploy the contract with a name and symbol | ||
``` | ||
deploy NFT.Init(name: "CryptoCocoNFT", symbol: "COCO") | ||
``` | ||
|
||
## 2. Mint three tokens to different addresses | ||
``` | ||
invoke NFT.mint(to: 0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b, tokenId: 1, tokenURI: "https://example.com/metadata/1") | ||
invoke NFT.mint(to: 0x2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3, tokenId: 2, tokenURI: "https://example.com/metadata/2") | ||
invoke NFT.mint(to: 0x3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4, tokenId: 3, tokenURI: "https://example.com/metadata/3") | ||
``` | ||
|
||
## 3. Check token ownership and balance for an address | ||
``` | ||
invoke NFT.ownerOf(tokenId: 1) | ||
invoke NFT.balanceOf(owner: 0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b) | ||
``` | ||
|
||
## 4. Approve another address to transfer a specific token | ||
``` | ||
invoke NFT.approve(to: 0x4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5, tokenId: 1) | ||
``` | ||
|
||
## 5. Check the approval status for a token | ||
``` | ||
invoke NFT.getApproved(tokenId: 1) | ||
``` | ||
|
||
## 6. Set approval for all tokens to an operator | ||
``` | ||
invoke NFT.setApprovalForAll(operator: 0x5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e, approved: true) | ||
``` | ||
|
||
## 7. Check if an address is approved for all tokens of an owner | ||
``` | ||
invoke NFT.isApprovedForAll(owner: 0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b, operator: 0x5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e) | ||
``` | ||
|
||
## 8. Transfer a token using the regular transfer method | ||
``` | ||
invoke NFT.transferFrom(from: 0x1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b, to: 0x6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7, tokenId: 1) | ||
``` | ||
|
||
## 9. Transfer a token using the safe transfer method | ||
``` | ||
invoke NFT.safeTransferFrom(from: 0x2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3, to: 0x7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8, tokenId: 2) | ||
``` | ||
|
||
## 10. Get the URI for a token | ||
``` | ||
invoke NFT.tokenURI(tokenId: 1) | ||
``` | ||
|
||
## 11. Get the contract name and symbol | ||
``` | ||
invoke NFT.name() | ||
invoke NFT.symbol() | ||
``` | ||
|
||
## 12. Get the total supply of tokens | ||
``` | ||
invoke NFT.totalSupply() | ||
``` | ||
|
||
## 13. Get a token by its index | ||
``` | ||
invoke NFT.tokenByIndex(index: 0) | ||
``` | ||
|
||
## 14. Get a token of a specific owner by index | ||
``` | ||
invoke NFT.tokenOfOwnerByIndex(owner: 0x3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4, index: 0) | ||
``` | ||
|
||
Note: Replace the example addresses with actual addresses when using this guide. Ensure that you have the necessary permissions to perform these operations on the NFT contract. |
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.
Uh oh!
There was an error while loading. Please reload this page.