From 0744133e4c94eb34c362bf4225b24261796d731d Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 5 Feb 2024 15:33:27 +0100 Subject: [PATCH 01/26] Move existing tutorials to the docs folder --- docs/reverse-lookup.md | 2 +- {tutorials => docs/tutorials}/custom-migration-tutorial.md | 0 {tutorials => docs/tutorials}/standard-migration-tutorial.md | 0 {tutorials => docs/tutorials}/token-ownership-tutorial.md | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {tutorials => docs/tutorials}/custom-migration-tutorial.md (100%) rename {tutorials => docs/tutorials}/standard-migration-tutorial.md (100%) rename {tutorials => docs/tutorials}/token-ownership-tutorial.md (100%) diff --git a/docs/reverse-lookup.md b/docs/reverse-lookup.md index 09bdd2aa..99f01fa3 100644 --- a/docs/reverse-lookup.md +++ b/docs/reverse-lookup.md @@ -1,6 +1,6 @@ # Owner Reverse Lookup Functionality -In version 1.0 of the CEP-78 Enhanced NFT Standard contract, tracking minted tokens consisted of a single, unbounded list that would grow in size with each additional token. As a result, gas costs would increase over time as the list must be overwritten with each new minting. The related tutorial can be found [here](../tutorials/token-ownership-tutorial.md). +In version 1.0 of the CEP-78 Enhanced NFT Standard contract, tracking minted tokens consisted of a single, unbounded list that would grow in size with each additional token. As a result, gas costs would increase over time as the list must be overwritten with each new minting. The related tutorial can be found [here](../docs/tutorials/token-ownership-tutorial.md). In an effort to stabilize the gas costs of larger NFT collections, version 1.1 of CEP-78 includes the use of a pre-allocated page system to track ownership of NFTs within the contract. diff --git a/tutorials/custom-migration-tutorial.md b/docs/tutorials/custom-migration-tutorial.md similarity index 100% rename from tutorials/custom-migration-tutorial.md rename to docs/tutorials/custom-migration-tutorial.md diff --git a/tutorials/standard-migration-tutorial.md b/docs/tutorials/standard-migration-tutorial.md similarity index 100% rename from tutorials/standard-migration-tutorial.md rename to docs/tutorials/standard-migration-tutorial.md diff --git a/tutorials/token-ownership-tutorial.md b/docs/tutorials/token-ownership-tutorial.md similarity index 100% rename from tutorials/token-ownership-tutorial.md rename to docs/tutorials/token-ownership-tutorial.md From e5a0c53c706a37a7528a641f2127a4d17486909f Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 5 Feb 2024 15:34:24 +0100 Subject: [PATCH 02/26] Updated links --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c5611c95..2e5db00d 100644 --- a/README.md +++ b/README.md @@ -104,11 +104,11 @@ folder within the project folder. ### Checking Token Ownership -[Learn to check token ownership](./tutorials/token-ownership-tutorial.md) starting with version [v1.1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.1). The `OwnerReverseLookupMode` modality must be set to `Complete` as described [here](/docs/reverse-lookup.md). +[Learn to check token ownership](./docs/tutorials/token-ownership-tutorial.md) starting with version [v1.1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.1). The `OwnerReverseLookupMode` modality must be set to `Complete` as described [here](/docs/reverse-lookup.md). ### Upgrading to Version 1.1.1 -Upgrade to v1.1.1 using a [Standard NamedKey Convention](./tutorials/standard-migration-tutorial.md) or a [Custom NamedKey Convention](./tutorials/custom-migration-tutorial.md). +Upgrade to v1.1.1 using a [Standard NamedKey Convention](./docs/tutorials/standard-migration-tutorial.md) or a [Custom NamedKey Convention](./docs/tutorials/custom-migration-tutorial.md). ## Installing and Interacting with the Contract using the Rust Casper Client From 3125b4599ceab0612cca4f6a9e0b1b8468febc40 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Wed, 14 Feb 2024 13:55:18 +0100 Subject: [PATCH 03/26] Add an initial full-tutorial --- docs/tutorials/full-tutorial.md | 274 ++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 docs/tutorials/full-tutorial.md diff --git a/docs/tutorials/full-tutorial.md b/docs/tutorials/full-tutorial.md new file mode 100644 index 00000000..63da20b4 --- /dev/null +++ b/docs/tutorials/full-tutorial.md @@ -0,0 +1,274 @@ +# A Casper NFT Tutorial + +This tutorial introduces an implementation of the CEP-78 standard for the Casper blockchain, known as the Casper Enhanced NFT standard. The code for this tutorial is available in [GitHub](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). + +The following functions implement the rules defined for Casper NFTs: `totalSupply`, `transfer`, `transferFrom`, `approve`, `balanceOf`, and `allowance`. A portion of this tutorial reviews the [contract](../../contract/src/main.rs). + +The [Writing Rust Contracts on Casper](https://docs.casper.network/developers/writing-onchain-code/simple-contract/) document outlines many aspects of this tutorial and should be read first. + +## Table of Contents + +1. [Environment Setup](#environment-setup) + - [Prerequisites](#prerequisites) + - [Building the Contract and Tests](#building-the-contract-and-tests) +2. [Reviewing the Contract Implementation](#reviewing-the-contract-implementation) + - [Required Crates](#required-crates) + - [Initialization Flow](#Initialization-flow) + - [Contract Entrypoints](#contract-entrypoints) +3. [Installing the Contract](#installing-the-contract) + - [Querying Global State](#querying-global-state) + - [Sending the Installation Deploy](#sending-the-installation-deploy) + - [Verifying the Installation](#verifying-the-installation) + - [Querying Contract Entry Points](#querying-contract-entry-points) + + +## Environment Setup + +### Prerequisites + +Before using this guide, ensure you meet the following requirements: + +- Set up the [development prerequisites](https://docs.casper.network/developers/prerequisites/), including the [Casper client](https://docs.casper.network/developers/prerequisites/#install-casper-client) +- Get a valid [node address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers), or use the following Testnet node: [https://rpc.testnet.casperlabs.io/](https://rpc.testnet.casperlabs.io/) +- Know how to install a [smart contract](https://docs.casper.network/developers/cli/sending-deploys/) on a Casper network +- Hold enough CSPR tokens to pay for transactions + +### Building the Contract and Tests + +First clone the contract from GitHub: + +```bash +git clone https://github.com/casper-ecosystem/cep-78-enhanced-nft/ && cd cep-78-enhanced-nft +``` + +Prepare your environment with the following command: + +```bash +make prepare +``` + +If your environment is set up correctly, you will see this output: + +```bash +rustup target add wasm32-unknown-unknown +info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date +``` + +If you do not see this message, check the [Getting Started Guide](https://docs.casper.network/developers/writing-onchain-code/getting-started/). + +Next, compile your contract and run the contract unit tests. + +```bash +make test +``` + +## Reviewing the Contract Implementation + +In this repository, you will find a library and an [example NFT implementation](../../contract/src/main.rs) for Casper networks. This section explains the example contract in more detail. + +There are four steps to follow when you intend to create your own implementation of the NFT contract, as follows: + +1. Fork the code from the example repository listed above. +2. Perform any customization changes necessary on your personal fork of the example contract. +3. Compile the customized code to Wasm. +4. Send the customized Wasm as a deploy to a Casper network. + +### Required Crates + +This tutorial applies to the Rust implementation of the Casper NFT standard, which requires the following Casper crates: + +- [casper_contract](https://docs.rs/casper-contract/latest/casper_contract/index.html) - A Rust library for writing smart contracts on Casper networks +- [casper_types](https://docs.rs/casper-types/latest/casper_types/) - Types used to allow creation of Wasm contracts and tests for use on Casper networks + +Here is the code snippet which imports those crates: + +```rust +use casper_contract::{ + contract_api::{ + runtime::{self, call_contract, revert}, + storage::{self}, + }, + unwrap_or_revert::UnwrapOrRevert, +}; +use casper_types::{ + contracts::NamedKeys, runtime_args, CLType, CLValue, ContractHash, ContractPackageHash, + EntryPoint, EntryPointAccess, EntryPointType, EntryPoints, Key, KeyTag, Parameter, RuntimeArgs, + Tagged, +}; +``` + +**Note**: In Rust, the keyword `use` is like an include statement in C/C++. + +The contract code defines additional modules in the `contract/src` folder: + +```rust +mod constants; +mod error; +mod events; +mod metadata; +mod modalities; +mod utils; +``` + +- `constants` - Constant values required to run the contract code +- `error` - Errors related to the NFT contract +- `events` - A library for contract-emitted events +- `metadata` - Module handling the contract's metadata and corresponding dictionary +- `modalities` - Common expectations around contract usage and behavior +- `utils` - Utility and helper functions to run the contract code + +### Initialization Flow + +Initializing the contract happens through the `call() -> install_contract() -> init()` functions inside the [main.rs](../../contract/src/main.rs) contract file. The `init()` function reads the runtime arguments and defines parameters such as `collection_name`, `collection_symbol`, and `total_token_supply`, among the other required and optional arguments described in the [README](../../README.md#required-runtime-arguments). + +### Contract Entrypoints + +This section briefly explains the essential entrypoints used in the Casper NFT contract. To see their full implementation, refer to the [main.rs](../../contract/src/main.rs) contract file. For further questions, contact the Casper support team via the [Discord channel](https://discord.com/invite/casperblockchain). The following entrypoints are listed as they are found in the code. + +- [**approve**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1002) - Allows a spender to transfer up to an amount of the owners’s tokens +- [**balance_of**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1616) - Returns the token balance of the owner +- [**burn**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L874) - Burns tokens, reducing the total supply +- [**get_approved**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1728) - Returns the hash of the approved account for a specified token identifier +- [**init**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L81) - Sets the collection name, symbol, and total token supply; initializes the allow minting setting, minting mode, ownership mode, NFT kind, holder mode, whitelist mode and contract whitelist, JSON schema, receipt name, identifier mode, and burn mode. This entrypoint can only be called once when the contract is installed on the network +- [**metadata**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1675) - Returns the metadata associated with a token identifier +- [**mint**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L619) - Mints additional tokens if mintin is allowed, increasing the total supply +- [**owner_of**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1636) - Returns the owner for a specified token identifier +- [**set_approval_for_all**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1254) - Allows a spender to transfer all of the owner's tokens +- [**set_token_metadata**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1773) - Sets the metadata associated with a token identifier +- [**set_variables**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L496) - Allows the user to set any combination of variables simultaneously, defining which variables are mutable or immutable +- [**transfer**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1359) - Transfers tokens from the token owner to a specified account. The transfer will succeed if the caller is the token owner or an approved operators. The transfer will fail if the OwnershipMode is set to Minter or Assigned + +There is also the [**migrate**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1975) entrypoint, which was needed only for migrating a 1.0 version of the NFT contract to version 1.1. + +## Installing the Contract + +After customizing your instance of the NFT contract, install it on the network, just like any other Casper contract. The following sections briefly cover the commands you need. Refer to [Sending Deploys to a Casper network using the Rust Client](https://docs.casper.network/developers/dapps/sending-deploys/) for more details. + +### Querying Global State + +This step queries information about the network state given the latest state root hash. You will also need the [IP address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers) from a Testnet peer node. + +```bash +casper-client get-state-root-hash --node-address https://rpc.testnet.casperlabs.io/ +``` + +### Querying the Account State + +Run the following command and supply the path to your public key in hexadecimal format to get the account hash, if you don't have it already. + +```bash +casper-client account-address --public-key "[PATH_TO_PUBLIC_KEY_HEX]" +``` + +Use the command below to query the state of your account. + +```bash +casper-client query-global-state --node-address http:// \ +--state-root-hash [STATE_ROOT_HASH] \ +--key [ACCOUNT_HASH] +``` + +
+Expand for a sample command + +```bash +casper-client query-global-state --node-address https://rpc.testnet.casperlabs.io/ \ +--state-root-hash e45cab47e15615cfe27c889b0a6446986077a1d6fb5b6a2be49d230273bc8d5b \ +--key account-hash-5cb74580bcf97d0a7fa034e60b3d2952e0b170ea5162153b1570e8b1ee4ec3f5 +``` + +
+ + + +### Sending the Installation Deploy + +Next, install the contract on the network. Use the Testnet to understand the exact gas amount required for installation. Refer to the [note about gas prices](https://docs.casper.network/developers/cli/sending-deploys/#a-note-about-gas-price) to understand payment amounts and gas price adjustments. + +```bash +casper-client put-deploy --node-address http:// \ +--chain-name [NETWORK_NAME] \ +--payment-amount [AMOUNT] \ +--secret-key [PATH_TO_SECRET_KEY] \ +--session-path [WASM_FILE_PATH] \ +--session-arg <"NAME:TYPE='VALUE'"> +``` + +- `NETWORK_NAME`: Use the relevant network name +- `PATH_TO_SECRET_KEY`: The path to your secret key +- `AMOUNT`: Gas amount in motes needed for deploy execution +- `WASM_FILE_PATH`: The location of the compiled NFT Wasm file +- `NAME:TYPE='VALUE'`: The required and optional arguments for installing the contract + +
+Expand for a sample query and response + +```bash +casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--payment-amount 200000000000 \ +--secret-key ~/KEYS/secret_key.pem \ +--session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ +--session-arg "collection_name:string='CEP-78-collection'" \ +--session-arg "collection_symbol:string='CEP78'" \ +--session-arg "total_token_supply:u64='100'" \ +--session-arg "ownership_mode:u8='2'" \ +--session-arg "nft_kind:u8='1'" \ +--session-arg "nft_metadata_kind:u8='0'" \ +--session-arg "json_schema:string='nft-schema'" \ +--session-arg "identifier_mode:u8='0'" \ +--session-arg "metadata_mutability:u8='0'" +``` + +This command will output the `deploy_hash`, which can be used in the next step to verify the installation. + +```bash +{ + "id": 931694842944790108, + "jsonrpc": "2.0", + "result": { + "api_version": "1.4.3", + "deploy_hash": "b00E59f8aBA5c7aB9...." + } +} +``` + +
+ + +### Verifying the Installation + +Verify the sent deploy using the `get-deploy` command. + +```bash +casper-client get-deploy --node-address https://rpc.testnet.casperlabs.io/ [DEPLOY_HASH] +``` + + + +### Querying Contract Entry Points + +This step will narrow down the context and check the status of a specific entry point using arguments. + +```bash +casper-client query-global-state --node-address http:// \ +--state-root-hash [STATE_ROOT_HASH] \ +--key [ACCOUNT_HASH] \ +-q "[CONTRACT_NAME/ARGUMENT]" +``` + + + +
+Expand querying the contract name + +```bash +casper-client query-global-state --node-address https://rpc.testnet.casperlabs.io/ \ +--state-root-hash e45cab47e15615cfe27c889b0a6446986077a1d6fb5b6a2be49d230273bc8d5b \ +--key account-hash-5cb74580bcf97d0a7fa034e60b3d2952e0b170ea5162153b1570e8b1ee4ec3f5 \ +-q "nft_collection/name" +``` + +
+ + From b9784c32cf4cc3c2b7e51a1fe0c3f0357f4d5552 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Wed, 14 Feb 2024 13:55:27 +0100 Subject: [PATCH 04/26] Add an initial quickstart --- docs/tutorials/quickstart-guide.md | 65 ++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 docs/tutorials/quickstart-guide.md diff --git a/docs/tutorials/quickstart-guide.md b/docs/tutorials/quickstart-guide.md new file mode 100644 index 00000000..4a3dcae2 --- /dev/null +++ b/docs/tutorials/quickstart-guide.md @@ -0,0 +1,65 @@ + +# Casper Fungible Token Quick Start Guide + +This quick start guide introduces you to the Casper client commands and Wasm files necessary to deploy a CEP-78 Casper Enhanced NFT contract to the [Casper Testnet](https://testnet.cspr.live/). To execute transactions on a Casper network involving NFTs, you will need some CSPR tokens to pay for the transactions. The Testnet provides test tokens using a [faucet](https://docs.casper.network/users/testnet-faucet/). + +For greater detail into the creation and mechanics of the Casper NFT contract, see the complete [Casper NFT Tutorial](./full-tutorial.md). + +## Prerequisites + +Before using this guide, ensure you meet the following requirements: + +- Set up the [development prerequisites](https://docs.casper.network/developers/prerequisites/), including the [Casper client](https://docs.casper.network/developers/prerequisites/#install-casper-client) +- Get a valid [node address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers), or use the following Testnet node: [https://rpc.testnet.casperlabs.io/](https://rpc.testnet.casperlabs.io/) +- Know how to install a [smart contract](https://docs.casper.network/developers/cli/sending-deploys/) on a Casper network +- Hold enough CSPR tokens to pay for transactions + +# Setup + +Clone the Casper NFT (CEP-78) [contract repository](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). + +```bash +git clone https://github.com/casper-ecosystem/cep-78-enhanced-nft/ && cd cep-78-enhanced-nft +``` + +Run the following commands to build the `contract.wasm` in the `contract/target/wasm32-unknown-unknown/release` directory and run the tests. + +```bash +make prepare +make test +``` + +The output of the command would end with the following message: + +```bash +test result: ok. 159 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 15.33s +``` + +## Installing the NFT Contract + +The following command will install a sample NFT contract on the Testnet: + +```bash +casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--payment-amount 200000000000 \ +--secret-key ~/KEYS/secret_key.pem \ +--session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ +--session-arg "collection_name:string='CEP-78-collection'" \ +--session-arg "collection_symbol:string='CEP78'" \ +--session-arg "total_token_supply:u64='100'" \ +--session-arg "ownership_mode:u8='2'" \ +--session-arg "nft_kind:u8='1'" \ +--session-arg "nft_metadata_kind:u8='0'" \ +--session-arg "json_schema:string='nft-schema'" \ +--session-arg "identifier_mode:u8='0'" \ +--session-arg "metadata_mutability:u8='0'" +``` + +### Next Steps + +Learn to query the contract, perform token transfers, set up approvals, and understand the testing framework. + +- [Exploring the NTF Contract](./2-query.md) +- [NFT Transfers and Allowances](./3-transfer.md) +- [Testing Framework for CEP-78](./4-tests.md) \ No newline at end of file From d77bfbed6202fe03a413ae045a260fd7a5e1ab61 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Wed, 14 Feb 2024 13:56:51 +0100 Subject: [PATCH 05/26] Fix title in quickstart --- docs/tutorials/quickstart-guide.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/tutorials/quickstart-guide.md b/docs/tutorials/quickstart-guide.md index 4a3dcae2..959a632a 100644 --- a/docs/tutorials/quickstart-guide.md +++ b/docs/tutorials/quickstart-guide.md @@ -1,5 +1,4 @@ - -# Casper Fungible Token Quick Start Guide +# Casper NFT Quick Start Guide This quick start guide introduces you to the Casper client commands and Wasm files necessary to deploy a CEP-78 Casper Enhanced NFT contract to the [Casper Testnet](https://testnet.cspr.live/). To execute transactions on a Casper network involving NFTs, you will need some CSPR tokens to pay for the transactions. The Testnet provides test tokens using a [faucet](https://docs.casper.network/users/testnet-faucet/). From ecd78755bb325bfce3ffc9aa14c3903d40f750a6 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Wed, 14 Feb 2024 13:57:38 +0100 Subject: [PATCH 06/26] Rename full tutorial to full installation tutorial --- .../tutorials/{full-tutorial.md => full-installation-tutorial.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/tutorials/{full-tutorial.md => full-installation-tutorial.md} (100%) diff --git a/docs/tutorials/full-tutorial.md b/docs/tutorials/full-installation-tutorial.md similarity index 100% rename from docs/tutorials/full-tutorial.md rename to docs/tutorials/full-installation-tutorial.md From 2f598e3b7e414f5dd88ba82e7da70de6eff3830f Mon Sep 17 00:00:00 2001 From: ipopescu Date: Wed, 14 Feb 2024 15:19:01 +0100 Subject: [PATCH 07/26] Initial query and updated links --- docs/tutorials/query.md | 400 +++++++++++++++++++++++++++++ docs/tutorials/quickstart-guide.md | 6 +- 2 files changed, 403 insertions(+), 3 deletions(-) create mode 100644 docs/tutorials/query.md diff --git a/docs/tutorials/query.md b/docs/tutorials/query.md new file mode 100644 index 00000000..b55855cc --- /dev/null +++ b/docs/tutorials/query.md @@ -0,0 +1,400 @@ +# Querying NFT Contracts + +This document covers different commands to query and interact with an NFT (CEP-78) contract instance. + +## Prerequisites + +- Install the contract using the [Quickstart](./quickstart-guide.md) or the [Full Installation](./full-installation-tutorial.md) tutorials + +## Querying the Contract + +First, identify the contract hash by looking at the account that installed the contract. Under the account's named keys, you will see a named key for the contract hash, which represents the stored contract. Copy this value and save it for future queries. + +
+Accessing the NFT Contract Hash +
+ +
+ +Next, query the contract details. + +```bash +casper-client query-global-state -n http:// \ +// This is the contract hash, which can be found within the `NamedKeys` of the account that sent the installing deploy. +--key hash-30767a108fedcb8872a0cec5eabb76f743f1bf3bbac9cac6e9c15355ae17d61a \ +// This is the most up to date state root hash, which can found by using the `get-state-root-hash` command in the Casper client. +--state-root-hash ca9ad2c99188cdbb8ceeccff16c6225b53b8c2e01dff945fb7ff3e33b427faf5 +``` + +
+Casper client command without comments + +```bash +casper-client query-global-state -n https://rpc.testnet.casperlabs.io/ \ +--key hash-30767a108fedcb8872a0cec5eabb76f743f1bf3bbac9cac6e9c15355ae17d61a \ +--state-root-hash ca9ad2c99188cdbb8ceeccff16c6225b53b8c2e01dff945fb7ff3e33b427faf5 +``` + +
+
+ +
+Expand to see the contract + +```json +{ + "jsonrpc": "2.0", + "id": -5249732042108614691, + "result": { + "api_version": "1.5.6", + "block_header": null, + "stored_value": { + "Contract": { + "contract_package_hash": "contract-package-c6bb687a72d0aa341317ef85cc8668c6627f0c1e8233ead4aa97e0399c9366ea", + "contract_wasm_hash": "contract-wasm-f8fadaf90a26db147a56005891b2fc7f33c90ea4d39f533078be36894d99cff1", + "named_keys": [ + { + "name": "allow_minting", + "key": "uref-f4aa245fb70fdc6557cbbc61703629f616a2d5c270ee0c427147947d8cd8b12c-007" + }, + { + "name": "balances", + "key": "uref-953333e2c0249bd7db687b43cb2585d0ad5356eb7be6c4f56479070d3c33c1dd-007" + }, + { + "name": "burn_mode", + "key": "uref-9791a13ce6c3d3251607073c75fb548dcf70a6a84f2847845b08b7e797a9b40b-007" + }, + { + "name": "burnt_tokens", + "key": "uref-704d3105e3ee90e3f072f04333dd1644a3617013588981b18fa01afe570b6a97-007" + }, + { + "name": "collection_name", + "key": "uref-2957503e067a14bb8017b17af807699998b17cb2889a351dce8aeb8d6c4672fd-007" + }, + { + "name": "collection_symbol", + "key": "uref-be0d965414348f285c698dc67371a7dbc8974d4cd957f1cf162f0d6ce2fe215b-007" + }, + { + "name": "contract_whitelist", + "key": "uref-b2dd80cc9ea15fee10c841e49eb2db724ca4af85b47be5d37793994d879e97ec-007" + }, + { + "name": "holder_mode", + "key": "uref-a561a0171e7bfffcfe7c8e487c0f4e3528a807152c27d5b235445a3aad21a016-007" + }, + { + "name": "identifier_mode", + "key": "uref-5f7b8694da08e7b7c9f7613cd02da4c19aa0f3b26db033c09e4d42920a5f284d-007" + }, + { + "name": "installer", + "key": "account-hash-5cb74580bcf97d0a7fa034e60b3d2952e0b170ea5162153b1570e8b1ee4ec3f5" + }, + { + "name": "json_schema", + "key": "uref-fcc796a2d21efbbf777d1e5f1e6436ab4b0ba9a308c63502b0a26f82b4e53f21-007" + }, + { + "name": "metadata_cep78", + "key": "uref-64e0268f09395f215ee71dd668ac3e6f8fbf6b9340ee88d0e5381996ae577c0e-007" + }, + { + "name": "metadata_custom_validated", + "key": "uref-000c5609c2f884d4ae1bb3406f3ba1a9ce5fbe03eaa8dd6edd6d42ea7d4e43e9-007" + }, + { + "name": "metadata_mutability", + "key": "uref-eabf6aa4701272e56012b3567403434368aac7f6d43b5c26cc3ab5b29e96d14b-007" + }, + { + "name": "metadata_nft721", + "key": "uref-585836baca4e24d53234671c7e70ab1f5d2d8ed9e6eb083218365d71700f7626-007" + }, + { + "name": "metadata_raw", + "key": "uref-5d7a570165127633392eb40e8b899fa7d5f0fc90f589e6d425994aac050a7cae-007" + }, + { + "name": "minting_mode", + "key": "uref-81a08d4b64c0a8c08ef75b164da3ae3914883224857632ab4f476f386e853d01-007" + }, + { + "name": "nft_kind", + "key": "uref-a50039ae7e9191fed14bff1b1404538189894d2bf7d279672c1b0ec4e7f6441b-007" + }, + { + "name": "nft_metadata_kind", + "key": "uref-0c8b9018f09e90d2823134cdf0d70cdec08decaaa822aa1311e79242b616e4d3-007" + }, + { + "name": "number_of_minted_tokens", + "key": "uref-c02c67cc721aa82ecd70adae2647b94125dde3fb4899a44ab03c944f3dfe7923-007" + }, + { + "name": "operator", + "key": "uref-6ced629a6c54e24ca0a2c4af0cce2a69139fac7461294234bd91b442886e0c13-007" + }, + { + "name": "owned_tokens", + "key": "uref-456e98216d72a0a1a0427fb6ddf4cc7070d1450faa841cf381c821c415092228-007" + }, + { + "name": "ownership_mode", + "key": "uref-b23f6166e076cc347ab0ba68343e51d3ecf9808e6a960386f5fc8af8cdce4df8-007" + }, + { + "name": "receipt_name", + "key": "uref-006512abe036cf2b923418a22c426fd59d88a812a8e3c478c630faa376e20832-007" + }, + { + "name": "token_issuers", + "key": "uref-5ba273a67b785a6580d0784362f09761c4bb9f0e261c8a583e74af0ab68fe010-007" + }, + { + "name": "token_owners", + "key": "uref-962891f947726ef87e6988d26ae5bb65c1376520278a149ea0044aafc94f3a91-007" + }, + { + "name": "total_token_supply", + "key": "uref-e2116be250c30901324f4590683774a83577a51b174274d371c38d574b065d90-007" + }, + { + "name": "whitelist_mode", + "key": "uref-ab9b9c51e591e56e8042a1ae6649dad31d52be6febc4aba62c414ff069089bf6-007" + } + ], + "entry_points": [ + { + "name": "approve", + "args": [ + { + "name": "operator", + "cl_type": "Key" + } + ], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "balance_of", + "args": [ + { + "name": "token_owner", + "cl_type": "Key" + } + ], + "ret": "U64", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "burn", + "args": [], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "get_approved", + "args": [], + "ret": { + "Option": "Key" + }, + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "init", + "args": [ + { + "name": "collection_name", + "cl_type": "String" + }, + { + "name": "collection_symbol", + "cl_type": "String" + }, + { + "name": "total_token_supply", + "cl_type": "U64" + }, + { + "name": "allow_minting", + "cl_type": "Bool" + }, + { + "name": "minting_mode", + "cl_type": "U8" + }, + { + "name": "ownership_mode", + "cl_type": "U8" + }, + { + "name": "nft_kind", + "cl_type": "U8" + }, + { + "name": "holder_mode", + "cl_type": "U8" + }, + { + "name": "whitelist_mode", + "cl_type": "U8" + }, + { + "name": "contract_whitelist", + "cl_type": { + "List": { + "ByteArray": 32 + } + } + }, + { + "name": "json_schema", + "cl_type": "String" + }, + { + "name": "receipt_name", + "cl_type": "String" + }, + { + "name": "identifier_mode", + "cl_type": "U8" + }, + { + "name": "burn_mode", + "cl_type": "U8" + } + ], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "metadata", + "args": [], + "ret": "String", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "mint", + "args": [ + { + "name": "token_owner", + "cl_type": "Key" + }, + { + "name": "token_meta_data", + "cl_type": "String" + } + ], + "ret": { + "Tuple3": [ + "String", + "Key", + "String" + ] + }, + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "owner_of", + "args": [], + "ret": "Key", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "set_approval_for_all", + "args": [ + { + "name": "token_owner", + "cl_type": "Key" + }, + { + "name": "approve_all", + "cl_type": "Bool" + }, + { + "name": "operator", + "cl_type": "Key" + } + ], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "set_token_metadata", + "args": [ + { + "name": "token_meta_data", + "cl_type": "String" + } + ], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "set_variables", + "args": [ + { + "name": "allow_minting", + "cl_type": "Bool" + }, + { + "name": "contract_whitelist", + "cl_type": { + "List": { + "ByteArray": 32 + } + } + } + ], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "transfer", + "args": [ + { + "name": "source_key", + "cl_type": "Key" + }, + { + "name": "target_key", + "cl_type": "Key" + } + ], + "ret": { + "Tuple2": [ + "String", + "Key" + ] + }, + "access": "Public", + "entry_point_type": "Contract" + } + ], + "protocol_version": "1.4.10" + } + }, + "merkle_proof": "[31286 hex chars]" + } +} +``` + +
+ +## Next Steps + +- [NFT Transfers](./transfer.md) \ No newline at end of file diff --git a/docs/tutorials/quickstart-guide.md b/docs/tutorials/quickstart-guide.md index 959a632a..bb072912 100644 --- a/docs/tutorials/quickstart-guide.md +++ b/docs/tutorials/quickstart-guide.md @@ -59,6 +59,6 @@ casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ \ Learn to query the contract, perform token transfers, set up approvals, and understand the testing framework. -- [Exploring the NTF Contract](./2-query.md) -- [NFT Transfers and Allowances](./3-transfer.md) -- [Testing Framework for CEP-78](./4-tests.md) \ No newline at end of file +- [Exploring the NTF Contract](./query.md) +- [NFT Transfers and Allowances](./transfer.md) +- [Testing Framework for CEP-78](./tests.md) \ No newline at end of file From ec76931842d1c8f05b194c989809c0c5f43d8ad3 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Thu, 15 Feb 2024 15:07:08 +0100 Subject: [PATCH 08/26] Initial transfer document + move files to a folder --- .../full-installation-tutorial.md | 13 +- docs/tutorials/{ => getting started}/query.md | 0 .../{ => getting started}/quickstart-guide.md | 2 +- docs/tutorials/getting started/transfer.md | 226 ++++++++++++++++++ 4 files changed, 233 insertions(+), 8 deletions(-) rename docs/tutorials/{ => getting started}/full-installation-tutorial.md (92%) rename docs/tutorials/{ => getting started}/query.md (100%) rename docs/tutorials/{ => getting started}/quickstart-guide.md (96%) create mode 100644 docs/tutorials/getting started/transfer.md diff --git a/docs/tutorials/full-installation-tutorial.md b/docs/tutorials/getting started/full-installation-tutorial.md similarity index 92% rename from docs/tutorials/full-installation-tutorial.md rename to docs/tutorials/getting started/full-installation-tutorial.md index 63da20b4..dc76c314 100644 --- a/docs/tutorials/full-installation-tutorial.md +++ b/docs/tutorials/getting started/full-installation-tutorial.md @@ -2,9 +2,7 @@ This tutorial introduces an implementation of the CEP-78 standard for the Casper blockchain, known as the Casper Enhanced NFT standard. The code for this tutorial is available in [GitHub](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). -The following functions implement the rules defined for Casper NFTs: `totalSupply`, `transfer`, `transferFrom`, `approve`, `balanceOf`, and `allowance`. A portion of this tutorial reviews the [contract](../../contract/src/main.rs). - -The [Writing Rust Contracts on Casper](https://docs.casper.network/developers/writing-onchain-code/simple-contract/) document outlines many aspects of this tutorial and should be read first. +The following functions implement the rules defined for Casper NFTs, and a portion of this tutorial reviews the [contract](../../../contract/src/main.rs). ## Table of Contents @@ -21,7 +19,6 @@ The [Writing Rust Contracts on Casper](https://docs.casper.network/developers/wr - [Verifying the Installation](#verifying-the-installation) - [Querying Contract Entry Points](#querying-contract-entry-points) - ## Environment Setup ### Prerequisites @@ -33,6 +30,8 @@ Before using this guide, ensure you meet the following requirements: - Know how to install a [smart contract](https://docs.casper.network/developers/cli/sending-deploys/) on a Casper network - Hold enough CSPR tokens to pay for transactions +The [Writing Rust Contracts on Casper](https://docs.casper.network/developers/writing-onchain-code/simple-contract/) document outlines many aspects of this tutorial and should be read as a prerequisite. + ### Building the Contract and Tests First clone the contract from GitHub: @@ -64,7 +63,7 @@ make test ## Reviewing the Contract Implementation -In this repository, you will find a library and an [example NFT implementation](../../contract/src/main.rs) for Casper networks. This section explains the example contract in more detail. +In this repository, you will find a library and an [example NFT implementation](../../../contract/src/main.rs) for Casper networks. This section explains the example contract in more detail. There are four steps to follow when you intend to create your own implementation of the NFT contract, as follows: @@ -119,11 +118,11 @@ mod utils; ### Initialization Flow -Initializing the contract happens through the `call() -> install_contract() -> init()` functions inside the [main.rs](../../contract/src/main.rs) contract file. The `init()` function reads the runtime arguments and defines parameters such as `collection_name`, `collection_symbol`, and `total_token_supply`, among the other required and optional arguments described in the [README](../../README.md#required-runtime-arguments). +Initializing the contract happens through the `call() -> install_contract() -> init()` functions inside the [main.rs](../../../contract/src/main.rs) contract file. The `init()` function reads the runtime arguments and defines parameters such as `collection_name`, `collection_symbol`, and `total_token_supply`, among the other required and optional arguments described in the [README](../../../README.md#required-runtime-arguments). ### Contract Entrypoints -This section briefly explains the essential entrypoints used in the Casper NFT contract. To see their full implementation, refer to the [main.rs](../../contract/src/main.rs) contract file. For further questions, contact the Casper support team via the [Discord channel](https://discord.com/invite/casperblockchain). The following entrypoints are listed as they are found in the code. +This section briefly explains the essential entrypoints used in the Casper NFT contract. To see their full implementation, refer to the [main.rs](../../../contract/src/main.rs) contract file. For further questions, contact the Casper support team via the [Discord channel](https://discord.com/invite/casperblockchain). The following entrypoints are listed as they are found in the code. - [**approve**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1002) - Allows a spender to transfer up to an amount of the owners’s tokens - [**balance_of**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1616) - Returns the token balance of the owner diff --git a/docs/tutorials/query.md b/docs/tutorials/getting started/query.md similarity index 100% rename from docs/tutorials/query.md rename to docs/tutorials/getting started/query.md diff --git a/docs/tutorials/quickstart-guide.md b/docs/tutorials/getting started/quickstart-guide.md similarity index 96% rename from docs/tutorials/quickstart-guide.md rename to docs/tutorials/getting started/quickstart-guide.md index bb072912..549423d2 100644 --- a/docs/tutorials/quickstart-guide.md +++ b/docs/tutorials/getting started/quickstart-guide.md @@ -2,7 +2,7 @@ This quick start guide introduces you to the Casper client commands and Wasm files necessary to deploy a CEP-78 Casper Enhanced NFT contract to the [Casper Testnet](https://testnet.cspr.live/). To execute transactions on a Casper network involving NFTs, you will need some CSPR tokens to pay for the transactions. The Testnet provides test tokens using a [faucet](https://docs.casper.network/users/testnet-faucet/). -For greater detail into the creation and mechanics of the Casper NFT contract, see the complete [Casper NFT Tutorial](./full-tutorial.md). +For greater detail into the creation and mechanics of the Casper NFT contract, see the complete [Casper NFT Tutorial](./full-installation-tutorial.md). ## Prerequisites diff --git a/docs/tutorials/getting started/transfer.md b/docs/tutorials/getting started/transfer.md new file mode 100644 index 00000000..8d506faa --- /dev/null +++ b/docs/tutorials/getting started/transfer.md @@ -0,0 +1,226 @@ +# NFT Transfers + +This document describes how to transfer NFTs on a Casper network using the Casper client. + +## Prerequisites + +- Install the contract using the [Quickstart](./quickstart-guide.md) or the [Full Installation](./full-installation-tutorial.md) tutorials +- Learn to [Query NFT Contracts](./query.md) and save the various hashes and URefs required throughout this document + +## Transferring NFTs to Another Account + +The following command invokes the `transfer` entrypoint on your instance of CEP-78, directing it to transfer 10 of the associated NFT tokens to another account. + +```bash +casper-client put-deploy -n http:// \ +// The chain name of the Casper network on which your CEP-78 instance was installed. +--chain-name [CHAIN_NAME] \ +// The local path to your account's secret key. +--secret-key [PATH_TO_SECRET_KEY] \ +// The contract hash of your CEP-78 contract instance. +--session-hash [CEP-78_CONTRACT_HASH] \ +// The name of the entry point you are invoking. +--session-entry-point "transfer" \ +// The account hash of the account that you are sending CEP-78 tokens to. +--session-arg "recipient:key='account-hash-[HASH]" \ +// The amount of CEP-78 tokens you are sending to the receiving account. +--session-arg "amount:u256='10'" \ +// The gas payment you are allotting, in motes. +--payment-amount "10000000000" +``` + +
+Sample command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-hash hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180 \ +--session-entry-point "transfer" \ +--session-arg "recipient:key='account-hash-9f81014b9c7406c531ebf0477132283f4eb59143d7903a2fae54358b26cea44b" \ +--session-arg "amount:u256='50'" \ +--payment-amount "10000000000" +``` + +
+ +This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance. + +### Invoking the `balance_of` Entry Point + +The following Casper client command invokes the `balance_of` entry point on the `cep78_test_contract`. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +--secret-key [PATH_TO_SECRET_KEY] \ +--session-package-name "cep78_test_contract" \ +--session-entry-point "balance_of" \ +// This is the contract hash of your CEP-78 contract instance, passed in as an `account-hash-`. +--session-arg "token_contract:account_hash='account-hash-[HASH]'" \ +// This is the account hash of the account you are checking the balance of. +--session-arg "address:key='account-hash-[HASH]'" \ +--payment-amount 1000000000 +``` + +
+Sample command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-package-name "cep78_test_contract" \ +--session-entry-point "balance_of" \ +--session-arg "token_contract:account_hash='account-hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180'" \ +--session-arg "address:key='account-hash-303c0f8208220fe9a4de40e1ada1d35fdd6c678877908f01fddb2a56502d67fd'" \ +--payment-amount 1000000000 +``` + +
+ +## Approving Another Account + +The Casper NFT contract features an `approve` entry point that allows an account to delegate another account to spend a preset number of CEP-78 tokens from their balance. + +The following command approves another account to spend 15 tokens from the balance of the account that installed and owns the CEP-78 contract instance. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +--secret-key [PATH_TO_SECRET_KEY] \ +// This is the contract hash of the CEP-78 token contract. +--session-hash [CEP-78_CONTRACT_HASH] \ +--session-entry-point "approve" \ +// This is the account hash of the account that will receive an allowance from the balance of the account that sent the Deploy. +--session-arg "spender:key='account-hash-[HASH]'" \ +// This is the number of CEP-78 tokens included in the allowance. +--session-arg "amount:u256='15'" \ +--payment-amount "10000000000" +``` + +
+Sample command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ +--session-entry-point "approve" \ +--session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ +--session-arg "amount:u256='15'" \ +--payment-amount "10000000000" +``` + +
+ +### Transferring Tokens from an Approved Account + +The following command allows an account to transfer CEP-78 tokens held by another account up to their approved allowance. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +// This is the secret key for the account that is spending their allowance from another account's balance. +--secret-key [PATH_TO_SECRET_KEY] \ +// This is the CEP-78 token contract. +--session-hash [CEP-78_CONTRACT_HASH] \ +--session-entry-point "transfer" \ +// This is the account hash of the account that holds the CEP-78 in their balance. +--session-arg "owner:key='account-hash-[HASH]'" \ +// This is the account hash of the account that will receive the transferred CEP-78 tokens. +--session-arg "recipient:key='account-hash-[HASH]'" \ +// This is the amount of tokens to be transferred. If this amount exceeds the allowance of the account sending the deploy, it will fail. +--session-arg "amount:u256='10'" \ +--payment-amount "10000000000" +``` + +
+Sample command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/\ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ +--session-entry-point "transfer" \ +--session-arg "owner:key='account-hash-39f15c23df9be1244572bb499fac62cbcad3cab2dc1438609842f602f943d7d2'" \ +--session-arg "recipient:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ +--session-arg "amount:u256='10'" \ +--payment-amount "10000000000" +``` +
+ +## Minting Tokens + +If the contract allows minting, the following command will mint a number of CEP-78 tokens to the account provided. This increases the total supply of the token in question. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +--secret-key [PATH_TO_SECRET_KEY] \ +--session-package-name "cep78_contract_package_CEP78" \ +--session-entry-point "mint" \ +// This is the account that will receive the newly minted CEP-78 tokens. +--session-arg "owner:key='account-hash-[HASH]'" \ +// This is the number of additional CEP-78 tokens to add to the total supply. +--session-arg "amount:U256='10'" \ +--payment-amount 1000000000 +``` + +
+Sample command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-package-name "cep78_contract_package_CEP78" \ +--session-entry-point "mint" \ +--session-arg "owner:key='account-hash-683f53f56926f54ef9584b07585b025c68415dc05f7b2e56749153574b83d5cd'" \ +--session-arg "amount:U256='10'" \ +--payment-amount 1000000000 +``` + +
+ +## Burning Tokens + +If the contract allows burning, the following command will burn a number of CEP-78 tokens from the account provided. This decreases the total supply of the token in question. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +--secret-key [PATH_TO_SECRET_KEY] \ +--session-package-name "cep78_contract_package_CEP78" \ +--session-entry-point "burn" \ +// This is the account that the tokens will be burned from. +--session-arg "owner:key='account-hash-[HASH]'" \ +// This is the number of CEP-78 tokens to remove from the total supply. +--session-arg "amount:U256='10'" \ +--payment-amount 1000000000 +``` + +
+Sample command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-package-name "cep78_contract_package_CEP78" \ +--session-entry-point "burn" \ +// This is the account that the tokens will be burned from. +--session-arg "owner:key='account-hash-683f53f56926f54ef9584b07585b025c68415dc05f7b2e56749153574b83d5cd'" \ +// This is the number of CEP-78 tokens to remove from the total supply. +--session-arg "amount:U256='10'" \ +--payment-amount 1000000000 +``` + +
+ +### Next Steps + +- [Testing Framework for CEP-78](./tests.md) \ No newline at end of file From 04b162d5e8cbd3e6c09eb0c480ec607663e4e531 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 16 Feb 2024 17:06:36 +0100 Subject: [PATCH 09/26] Add a brief testing file --- docs/tutorials/getting started/tests.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/tutorials/getting started/tests.md diff --git a/docs/tutorials/getting started/tests.md b/docs/tutorials/getting started/tests.md new file mode 100644 index 00000000..c9df5ff9 --- /dev/null +++ b/docs/tutorials/getting started/tests.md @@ -0,0 +1,25 @@ +# Testing NFT Contracts + +## Prerequisites + +- Install the contract using the [Quickstart](./quickstart-guide.md) or the [Full Installation](./full-installation-tutorial.md) tutorials + +## Framework Description + +The testing framework in this tutorial uses the [Casper engine test support](https://crates.io/crates/casper-engine-test-support) crate for testing the contract implementation against the Casper execution environment. + +The [tests](../../../tests/) folder contains over 150 tests covering a variety of scenarios including contract installation, minting and burning tokens, sending transfers, upgrading the contract and listening to events. + +For more details about the test framework and how each test is setup, visit the [Testing Smart Contracts](https://docs.casper.network/developers/writing-onchain-code/testing-contracts/) documentation page. + +## Running the Tests + +To build and run the tests, issue the following command in the project folder: + +```bash +make test +``` + +The project contains a [Makefile](../../../Makefile), which is a custom build script that compiles the contract before running tests in _release_ mode. Then, the script copies the `contract.wasm` file to the corresponding version folder in the [tests/wasm](../../../tests/wasm/) directory. In practice, you only need to run the `make test` command during development, without having to build the contract separately. + +This example uses `bash`. If you are using a Rust IDE, you need to configure it to run the tests. \ No newline at end of file From 8e4b050f4f5d60550556bb5ee74c7d489e57808c Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 16 Feb 2024 17:20:03 +0100 Subject: [PATCH 10/26] Minor edits --- .../full-installation-tutorial.md | 14 ++++---- docs/tutorials/getting started/query.md | 6 ++-- docs/tutorials/getting started/tests.md | 8 ++--- docs/tutorials/getting started/transfer.md | 32 +++++++++---------- 4 files changed, 29 insertions(+), 31 deletions(-) diff --git a/docs/tutorials/getting started/full-installation-tutorial.md b/docs/tutorials/getting started/full-installation-tutorial.md index dc76c314..c279f9b4 100644 --- a/docs/tutorials/getting started/full-installation-tutorial.md +++ b/docs/tutorials/getting started/full-installation-tutorial.md @@ -65,10 +65,10 @@ make test In this repository, you will find a library and an [example NFT implementation](../../../contract/src/main.rs) for Casper networks. This section explains the example contract in more detail. -There are four steps to follow when you intend to create your own implementation of the NFT contract, as follows: +There are four steps to follow when you intend to create your implementation of the NFT contract, as follows: 1. Fork the code from the example repository listed above. -2. Perform any customization changes necessary on your personal fork of the example contract. +2. Perform any necessary customization changes on your fork of the example contract. 3. Compile the customized code to Wasm. 4. Send the customized Wasm as a deploy to a Casper network. @@ -77,9 +77,9 @@ There are four steps to follow when you intend to create your own implementation This tutorial applies to the Rust implementation of the Casper NFT standard, which requires the following Casper crates: - [casper_contract](https://docs.rs/casper-contract/latest/casper_contract/index.html) - A Rust library for writing smart contracts on Casper networks -- [casper_types](https://docs.rs/casper-types/latest/casper_types/) - Types used to allow creation of Wasm contracts and tests for use on Casper networks +- [casper_types](https://docs.rs/casper-types/latest/casper_types/) - Types used to allow the creation of Wasm contracts and tests for use on Casper networks -Here is the code snippet which imports those crates: +Here is the code snippet that imports those crates: ```rust use casper_contract::{ @@ -130,12 +130,12 @@ This section briefly explains the essential entrypoints used in the Casper NFT c - [**get_approved**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1728) - Returns the hash of the approved account for a specified token identifier - [**init**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L81) - Sets the collection name, symbol, and total token supply; initializes the allow minting setting, minting mode, ownership mode, NFT kind, holder mode, whitelist mode and contract whitelist, JSON schema, receipt name, identifier mode, and burn mode. This entrypoint can only be called once when the contract is installed on the network - [**metadata**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1675) - Returns the metadata associated with a token identifier -- [**mint**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L619) - Mints additional tokens if mintin is allowed, increasing the total supply +- [**mint**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L619) - Mints additional tokens if minting is allowed, increasing the total supply - [**owner_of**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1636) - Returns the owner for a specified token identifier - [**set_approval_for_all**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1254) - Allows a spender to transfer all of the owner's tokens - [**set_token_metadata**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1773) - Sets the metadata associated with a token identifier - [**set_variables**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L496) - Allows the user to set any combination of variables simultaneously, defining which variables are mutable or immutable -- [**transfer**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1359) - Transfers tokens from the token owner to a specified account. The transfer will succeed if the caller is the token owner or an approved operators. The transfer will fail if the OwnershipMode is set to Minter or Assigned +- [**transfer**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1359) - Transfers tokens from the token owner to a specified account. The transfer will succeed if the caller is the token owner or an approved operator. The transfer will fail if the OwnershipMode is set to Minter or Assigned There is also the [**migrate**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1975) entrypoint, which was needed only for migrating a 1.0 version of the NFT contract to version 1.1. @@ -153,7 +153,7 @@ casper-client get-state-root-hash --node-address https://rpc.testnet.casperlabs. ### Querying the Account State -Run the following command and supply the path to your public key in hexadecimal format to get the account hash, if you don't have it already. +Run the following command and supply the path to your public key in hexadecimal format to get the account hash if you don't have it already. ```bash casper-client account-address --public-key "[PATH_TO_PUBLIC_KEY_HEX]" diff --git a/docs/tutorials/getting started/query.md b/docs/tutorials/getting started/query.md index b55855cc..24bac9f4 100644 --- a/docs/tutorials/getting started/query.md +++ b/docs/tutorials/getting started/query.md @@ -8,7 +8,7 @@ This document covers different commands to query and interact with an NFT (CEP-7 ## Querying the Contract -First, identify the contract hash by looking at the account that installed the contract. Under the account's named keys, you will see a named key for the contract hash, which represents the stored contract. Copy this value and save it for future queries. +First, identify the contract hash by looking at the account that installed the contract. Under the account's named keys, you will see a named key for the contract hash, representing the stored contract. Copy this value and save it for future queries.
Accessing the NFT Contract Hash @@ -20,9 +20,9 @@ Next, query the contract details. ```bash casper-client query-global-state -n http:// \ -// This is the contract hash, which can be found within the `NamedKeys` of the account that sent the installing deploy. +// This is the contract hash, found within the `NamedKeys` of the account that sent the installing deploy. --key hash-30767a108fedcb8872a0cec5eabb76f743f1bf3bbac9cac6e9c15355ae17d61a \ -// This is the most up to date state root hash, which can found by using the `get-state-root-hash` command in the Casper client. +// This is the most up-to-date state root hash, which can be found by using the `get-state-root-hash` command in the Casper client. --state-root-hash ca9ad2c99188cdbb8ceeccff16c6225b53b8c2e01dff945fb7ff3e33b427faf5 ``` diff --git a/docs/tutorials/getting started/tests.md b/docs/tutorials/getting started/tests.md index c9df5ff9..5d0bfa23 100644 --- a/docs/tutorials/getting started/tests.md +++ b/docs/tutorials/getting started/tests.md @@ -8,9 +8,9 @@ The testing framework in this tutorial uses the [Casper engine test support](https://crates.io/crates/casper-engine-test-support) crate for testing the contract implementation against the Casper execution environment. -The [tests](../../../tests/) folder contains over 150 tests covering a variety of scenarios including contract installation, minting and burning tokens, sending transfers, upgrading the contract and listening to events. +The [tests](../../../tests/) folder contains over 150 tests covering a variety of scenarios, including contract installation, minting and burning tokens, sending transfers, upgrading the contract, and listening to events. -For more details about the test framework and how each test is setup, visit the [Testing Smart Contracts](https://docs.casper.network/developers/writing-onchain-code/testing-contracts/) documentation page. +For more details about the test framework and how each test is set up, visit the [Testing Smart Contracts](https://docs.casper.network/developers/writing-onchain-code/testing-contracts/) documentation page. ## Running the Tests @@ -20,6 +20,6 @@ To build and run the tests, issue the following command in the project folder: make test ``` -The project contains a [Makefile](../../../Makefile), which is a custom build script that compiles the contract before running tests in _release_ mode. Then, the script copies the `contract.wasm` file to the corresponding version folder in the [tests/wasm](../../../tests/wasm/) directory. In practice, you only need to run the `make test` command during development, without having to build the contract separately. +The project contains a [Makefile](../../../Makefile), which is a custom build script that compiles the contract before running tests in _release_ mode. Then, the script copies the `contract.wasm` file to the corresponding version folder in the [tests/wasm](../../../tests/wasm/) directory. In practice, you only need to run the `make test` command during development without building the contract separately. -This example uses `bash`. If you are using a Rust IDE, you need to configure it to run the tests. \ No newline at end of file +This example uses `bash`. If you use a Rust IDE, you must configure it to run the tests. \ No newline at end of file diff --git a/docs/tutorials/getting started/transfer.md b/docs/tutorials/getting started/transfer.md index 8d506faa..e4f2f89a 100644 --- a/docs/tutorials/getting started/transfer.md +++ b/docs/tutorials/getting started/transfer.md @@ -21,7 +21,7 @@ casper-client put-deploy -n http:// \ --session-hash [CEP-78_CONTRACT_HASH] \ // The name of the entry point you are invoking. --session-entry-point "transfer" \ -// The account hash of the account that you are sending CEP-78 tokens to. +// The account hash of the account to which you are sending CEP-78 tokens. --session-arg "recipient:key='account-hash-[HASH]" \ // The amount of CEP-78 tokens you are sending to the receiving account. --session-arg "amount:u256='10'" \ @@ -57,9 +57,9 @@ casper-client put-deploy -n http:// \ --secret-key [PATH_TO_SECRET_KEY] \ --session-package-name "cep78_test_contract" \ --session-entry-point "balance_of" \ -// This is the contract hash of your CEP-78 contract instance, passed in as an `account-hash-`. +// The contract hash of your CEP-78 contract instance, passed in as an `account-hash-`. --session-arg "token_contract:account_hash='account-hash-[HASH]'" \ -// This is the account hash of the account you are checking the balance of. +// The account hash of the account whose balance you are checking. --session-arg "address:key='account-hash-[HASH]'" \ --payment-amount 1000000000 ``` @@ -90,12 +90,12 @@ The following command approves another account to spend 15 tokens from the balan casper-client put-deploy -n http:// \ --chain-name [CHAIN_NAME] \ --secret-key [PATH_TO_SECRET_KEY] \ -// This is the contract hash of the CEP-78 token contract. +// The contract hash of the CEP-78 token contract. --session-hash [CEP-78_CONTRACT_HASH] \ --session-entry-point "approve" \ -// This is the account hash of the account that will receive an allowance from the balance of the account that sent the Deploy. +// The account hash of the account that will receive an allowance from the balance of the account that sent the Deploy. --session-arg "spender:key='account-hash-[HASH]'" \ -// This is the number of CEP-78 tokens included in the allowance. +// The number of CEP-78 tokens included in the allowance. --session-arg "amount:u256='15'" \ --payment-amount "10000000000" ``` @@ -123,16 +123,16 @@ The following command allows an account to transfer CEP-78 tokens held by anothe ```bash casper-client put-deploy -n http:// \ --chain-name [CHAIN_NAME] \ -// This is the secret key for the account that is spending their allowance from another account's balance. +// The secret key for the account that is spending their allowance from another account's balance. --secret-key [PATH_TO_SECRET_KEY] \ -// This is the CEP-78 token contract. +// The CEP-78 token contract. --session-hash [CEP-78_CONTRACT_HASH] \ --session-entry-point "transfer" \ -// This is the account hash of the account that holds the CEP-78 in their balance. +// The account hash of the account that holds the CEP-78 in their balance. --session-arg "owner:key='account-hash-[HASH]'" \ -// This is the account hash of the account that will receive the transferred CEP-78 tokens. +// The account hash of the account that will receive the transferred CEP-78 tokens. --session-arg "recipient:key='account-hash-[HASH]'" \ -// This is the amount of tokens to be transferred. If this amount exceeds the allowance of the account sending the deploy, it will fail. +// The amount of tokens to be transferred. If this amount exceeds the allowance of the account sending the deploy, it will fail. --session-arg "amount:u256='10'" \ --payment-amount "10000000000" ``` @@ -163,9 +163,9 @@ casper-client put-deploy -n http:// \ --secret-key [PATH_TO_SECRET_KEY] \ --session-package-name "cep78_contract_package_CEP78" \ --session-entry-point "mint" \ -// This is the account that will receive the newly minted CEP-78 tokens. +// This account will receive the newly minted CEP-78 tokens. --session-arg "owner:key='account-hash-[HASH]'" \ -// This is the number of additional CEP-78 tokens to add to the total supply. +// The number of additional CEP-78 tokens to add to the total supply. --session-arg "amount:U256='10'" \ --payment-amount 1000000000 ``` @@ -196,9 +196,9 @@ casper-client put-deploy -n http:// \ --secret-key [PATH_TO_SECRET_KEY] \ --session-package-name "cep78_contract_package_CEP78" \ --session-entry-point "burn" \ -// This is the account that the tokens will be burned from. +// The account from which the tokens will be burned. --session-arg "owner:key='account-hash-[HASH]'" \ -// This is the number of CEP-78 tokens to remove from the total supply. +// The number of CEP-78 tokens to remove from the total supply. --session-arg "amount:U256='10'" \ --payment-amount 1000000000 ``` @@ -212,9 +212,7 @@ casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ --secret-key ~/KEYS/secret_key.pem \ --session-package-name "cep78_contract_package_CEP78" \ --session-entry-point "burn" \ -// This is the account that the tokens will be burned from. --session-arg "owner:key='account-hash-683f53f56926f54ef9584b07585b025c68415dc05f7b2e56749153574b83d5cd'" \ -// This is the number of CEP-78 tokens to remove from the total supply. --session-arg "amount:U256='10'" \ --payment-amount 1000000000 ``` From 2a8da0f70060beaefb39bef10a78bf245e4875aa Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 16 Feb 2024 18:44:00 +0100 Subject: [PATCH 11/26] Move content frm using-casper-client.md to new tutorials --- README.md | 4 +- docs/tutorials/getting started/transfer.md | 224 ------------ .../full-installation-tutorial.md | 97 +++--- .../getting-started/interacting-with-NFTs.md | 327 ++++++++++++++++++ .../querying-NFTs.md} | 2 +- .../quickstart-guide.md | 6 +- .../testing-NFTs.md} | 0 docs/using-casper-client.md | 237 ------------- 8 files changed, 386 insertions(+), 511 deletions(-) delete mode 100644 docs/tutorials/getting started/transfer.md rename docs/tutorials/{getting started => getting-started}/full-installation-tutorial.md (73%) create mode 100644 docs/tutorials/getting-started/interacting-with-NFTs.md rename docs/tutorials/{getting started/query.md => getting-started/querying-NFTs.md} (99%) rename docs/tutorials/{getting started => getting-started}/quickstart-guide.md (94%) rename docs/tutorials/{getting started/tests.md => getting-started/testing-NFTs.md} (100%) delete mode 100644 docs/using-casper-client.md diff --git a/README.md b/README.md index 2e5db00d..b9f6e025 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ The following are the optional parameters that can be passed in at the time of i #### Example deploy -The following is an example of installing the NFT contract via a deploy using the Rust CLI Casper client. You can find more examples [here](/docs/using-casper-client.md). +The following is an example of installing the NFT contract via a deploy using the Rust CLI Casper client. You can find more examples [here](/docs/tutorials/getting-started/full-installation-tutorial.md). ```bash casper-client put-deploy -n http://65.108.0.148:7777/rpc --chain-name "casper-test" --payment-amount 500000000000 -k keys/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ @@ -112,7 +112,7 @@ Upgrade to v1.1.1 using a [Standard NamedKey Convention](./docs/tutorials/standa ## Installing and Interacting with the Contract using the Rust Casper Client -You can find instructions on installing an instance of the CEP-78 contract using the Rust CLI Casper client [here](/docs/using-casper-client.md). +You can find instructions on installing an instance of the CEP-78 contract using the Rust CLI Casper client [here](/docs/tutorials/getting-started/full-installation-tutorial.md). ## Test Suite and Specification diff --git a/docs/tutorials/getting started/transfer.md b/docs/tutorials/getting started/transfer.md deleted file mode 100644 index e4f2f89a..00000000 --- a/docs/tutorials/getting started/transfer.md +++ /dev/null @@ -1,224 +0,0 @@ -# NFT Transfers - -This document describes how to transfer NFTs on a Casper network using the Casper client. - -## Prerequisites - -- Install the contract using the [Quickstart](./quickstart-guide.md) or the [Full Installation](./full-installation-tutorial.md) tutorials -- Learn to [Query NFT Contracts](./query.md) and save the various hashes and URefs required throughout this document - -## Transferring NFTs to Another Account - -The following command invokes the `transfer` entrypoint on your instance of CEP-78, directing it to transfer 10 of the associated NFT tokens to another account. - -```bash -casper-client put-deploy -n http:// \ -// The chain name of the Casper network on which your CEP-78 instance was installed. ---chain-name [CHAIN_NAME] \ -// The local path to your account's secret key. ---secret-key [PATH_TO_SECRET_KEY] \ -// The contract hash of your CEP-78 contract instance. ---session-hash [CEP-78_CONTRACT_HASH] \ -// The name of the entry point you are invoking. ---session-entry-point "transfer" \ -// The account hash of the account to which you are sending CEP-78 tokens. ---session-arg "recipient:key='account-hash-[HASH]" \ -// The amount of CEP-78 tokens you are sending to the receiving account. ---session-arg "amount:u256='10'" \ -// The gas payment you are allotting, in motes. ---payment-amount "10000000000" -``` - -
-Sample command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-hash hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180 \ ---session-entry-point "transfer" \ ---session-arg "recipient:key='account-hash-9f81014b9c7406c531ebf0477132283f4eb59143d7903a2fae54358b26cea44b" \ ---session-arg "amount:u256='50'" \ ---payment-amount "10000000000" -``` - -
- -This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance. - -### Invoking the `balance_of` Entry Point - -The following Casper client command invokes the `balance_of` entry point on the `cep78_test_contract`. - -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ ---secret-key [PATH_TO_SECRET_KEY] \ ---session-package-name "cep78_test_contract" \ ---session-entry-point "balance_of" \ -// The contract hash of your CEP-78 contract instance, passed in as an `account-hash-`. ---session-arg "token_contract:account_hash='account-hash-[HASH]'" \ -// The account hash of the account whose balance you are checking. ---session-arg "address:key='account-hash-[HASH]'" \ ---payment-amount 1000000000 -``` - -
-Sample command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-package-name "cep78_test_contract" \ ---session-entry-point "balance_of" \ ---session-arg "token_contract:account_hash='account-hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180'" \ ---session-arg "address:key='account-hash-303c0f8208220fe9a4de40e1ada1d35fdd6c678877908f01fddb2a56502d67fd'" \ ---payment-amount 1000000000 -``` - -
- -## Approving Another Account - -The Casper NFT contract features an `approve` entry point that allows an account to delegate another account to spend a preset number of CEP-78 tokens from their balance. - -The following command approves another account to spend 15 tokens from the balance of the account that installed and owns the CEP-78 contract instance. - -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ ---secret-key [PATH_TO_SECRET_KEY] \ -// The contract hash of the CEP-78 token contract. ---session-hash [CEP-78_CONTRACT_HASH] \ ---session-entry-point "approve" \ -// The account hash of the account that will receive an allowance from the balance of the account that sent the Deploy. ---session-arg "spender:key='account-hash-[HASH]'" \ -// The number of CEP-78 tokens included in the allowance. ---session-arg "amount:u256='15'" \ ---payment-amount "10000000000" -``` - -
-Sample command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ ---session-entry-point "approve" \ ---session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ ---session-arg "amount:u256='15'" \ ---payment-amount "10000000000" -``` - -
- -### Transferring Tokens from an Approved Account - -The following command allows an account to transfer CEP-78 tokens held by another account up to their approved allowance. - -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ -// The secret key for the account that is spending their allowance from another account's balance. ---secret-key [PATH_TO_SECRET_KEY] \ -// The CEP-78 token contract. ---session-hash [CEP-78_CONTRACT_HASH] \ ---session-entry-point "transfer" \ -// The account hash of the account that holds the CEP-78 in their balance. ---session-arg "owner:key='account-hash-[HASH]'" \ -// The account hash of the account that will receive the transferred CEP-78 tokens. ---session-arg "recipient:key='account-hash-[HASH]'" \ -// The amount of tokens to be transferred. If this amount exceeds the allowance of the account sending the deploy, it will fail. ---session-arg "amount:u256='10'" \ ---payment-amount "10000000000" -``` - -
-Sample command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/\ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ ---session-entry-point "transfer" \ ---session-arg "owner:key='account-hash-39f15c23df9be1244572bb499fac62cbcad3cab2dc1438609842f602f943d7d2'" \ ---session-arg "recipient:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ ---session-arg "amount:u256='10'" \ ---payment-amount "10000000000" -``` -
- -## Minting Tokens - -If the contract allows minting, the following command will mint a number of CEP-78 tokens to the account provided. This increases the total supply of the token in question. - -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ ---secret-key [PATH_TO_SECRET_KEY] \ ---session-package-name "cep78_contract_package_CEP78" \ ---session-entry-point "mint" \ -// This account will receive the newly minted CEP-78 tokens. ---session-arg "owner:key='account-hash-[HASH]'" \ -// The number of additional CEP-78 tokens to add to the total supply. ---session-arg "amount:U256='10'" \ ---payment-amount 1000000000 -``` - -
-Sample command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-package-name "cep78_contract_package_CEP78" \ ---session-entry-point "mint" \ ---session-arg "owner:key='account-hash-683f53f56926f54ef9584b07585b025c68415dc05f7b2e56749153574b83d5cd'" \ ---session-arg "amount:U256='10'" \ ---payment-amount 1000000000 -``` - -
- -## Burning Tokens - -If the contract allows burning, the following command will burn a number of CEP-78 tokens from the account provided. This decreases the total supply of the token in question. - -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ ---secret-key [PATH_TO_SECRET_KEY] \ ---session-package-name "cep78_contract_package_CEP78" \ ---session-entry-point "burn" \ -// The account from which the tokens will be burned. ---session-arg "owner:key='account-hash-[HASH]'" \ -// The number of CEP-78 tokens to remove from the total supply. ---session-arg "amount:U256='10'" \ ---payment-amount 1000000000 -``` - -
-Sample command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-package-name "cep78_contract_package_CEP78" \ ---session-entry-point "burn" \ ---session-arg "owner:key='account-hash-683f53f56926f54ef9584b07585b025c68415dc05f7b2e56749153574b83d5cd'" \ ---session-arg "amount:U256='10'" \ ---payment-amount 1000000000 -``` - -
- -### Next Steps - -- [Testing Framework for CEP-78](./tests.md) \ No newline at end of file diff --git a/docs/tutorials/getting started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md similarity index 73% rename from docs/tutorials/getting started/full-installation-tutorial.md rename to docs/tutorials/getting-started/full-installation-tutorial.md index c279f9b4..a180c3b3 100644 --- a/docs/tutorials/getting started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -1,8 +1,8 @@ -# A Casper NFT Tutorial +# Installing an NFT Contract using the Rust Casper Client -This tutorial introduces an implementation of the CEP-78 standard for the Casper blockchain, known as the Casper Enhanced NFT standard. The code for this tutorial is available in [GitHub](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). +This documentation will guide you through the process of installing and interacting with an instance of the CEP-78 enhanced NFT standard contract through Casper's Rust CLI client. The contract code installs an instance of CEP-78 as per session arguments provided at the time of installation. It requires a minimum Rust version of `1.63.0`. The code for this tutorial is available in [GitHub](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). A portion of this tutorial reviews the [contract](../../../contract/src/main.rs). -The following functions implement the rules defined for Casper NFTs, and a portion of this tutorial reviews the [contract](../../../contract/src/main.rs). +Information on the modalities used throughout this installation process can be found in the [modalities documentation](modalities.md). ## Table of Contents @@ -17,7 +17,7 @@ The following functions implement the rules defined for Casper NFTs, and a porti - [Querying Global State](#querying-global-state) - [Sending the Installation Deploy](#sending-the-installation-deploy) - [Verifying the Installation](#verifying-the-installation) - - [Querying Contract Entry Points](#querying-contract-entry-points) +4. [Next Steps](#next-steps) ## Environment Setup @@ -55,7 +55,9 @@ info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date If you do not see this message, check the [Getting Started Guide](https://docs.casper.network/developers/writing-onchain-code/getting-started/). -Next, compile your contract and run the contract unit tests. +The contract code can be compiled to Wasm by running the `make build-contract` command provided in the Makefile at the top level. The Wasm will be found in the `contract/target/wasm32-unknown-unknown/release` directory as `contract.wasm`. + +You can also compile your contract and run the contract unit tests with this command: ```bash make test @@ -141,7 +143,7 @@ There is also the [**migrate**](https://github.com/casper-ecosystem/cep-78-enhan ## Installing the Contract -After customizing your instance of the NFT contract, install it on the network, just like any other Casper contract. The following sections briefly cover the commands you need. Refer to [Sending Deploys to a Casper network using the Rust Client](https://docs.casper.network/developers/dapps/sending-deploys/) for more details. +Installing the enhanced NFT contract to global state requires the use of a [Deploy](https://docs.casper.network/developers/dapps/sending-deploys/). But before proceeding with the installation, verify the network state and the status of the account that will send the installation deploy. ### Querying Global State @@ -182,22 +184,50 @@ casper-client query-global-state --node-address https://rpc.testnet.casperlabs.i ### Sending the Installation Deploy -Next, install the contract on the network. Use the Testnet to understand the exact gas amount required for installation. Refer to the [note about gas prices](https://docs.casper.network/developers/cli/sending-deploys/#a-note-about-gas-price) to understand payment amounts and gas price adjustments. +Below is an example of a `casper-client` command that provides all required session arguments to install a valid instance of the CEP-78 contract on global state. -```bash -casper-client put-deploy --node-address http:// \ ---chain-name [NETWORK_NAME] \ ---payment-amount [AMOUNT] \ ---secret-key [PATH_TO_SECRET_KEY] \ ---session-path [WASM_FILE_PATH] \ ---session-arg <"NAME:TYPE='VALUE'"> -``` +Use the Testnet to understand the exact gas amount required for installation. Refer to the [note about gas prices](https://docs.casper.network/developers/cli/sending-deploys/#a-note-about-gas-price) to understand payment amounts and gas price adjustments. + +- `casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 200000000000 --secret-key ~/KEYS/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm` + +1. `--session-arg "collection_name:string='CEP-78-collection'"` + + The name of the NFT collection as a string. In this instance, "CEP-78-collection". + +2. `--session-arg "collection_symbol:string='CEP78'"` + + The symbol representing the NFT collection as a string. In this instance, "CEP78". + +3. `--session-arg "total_token_supply:u64='100'"` + + The total supply of tokens to be minted. In this instance, 100. If the contract owner is unsure of the total number of NFTs they will require, they should err on the side of caution. + +4. `--session-arg "ownership_mode:u8='2'"` + + The ownership mode for this contract. In this instance the 2 represents "Transferable" mode. Under these conditions, users can freely transfer their NFTs between one another. + +5. `--session-arg "nft_kind:u8='1'"` + + The type of commodity represented by these NFTs. In this instance, the 1 represents a digital collection. + +6. `--session-arg "nft_metadata_kind:u8='0'"` + + The type of metadata used by this contract. In this instance, the 0 represents CEP-78 standard for metadata. + +7. `--session-arg "json_schema:string=''"` + + An empty JSON string, as the contract has awareness of the CEP-78 JSON schema. Using the custom validated modality would require passing through a valid JSON schema for your custom metadata. + +8. `--session-arg "identifier_mode:u8='0'"` + + The mode used to identify individual NFTs. For 0, this means an ordinal identification sequence rather than by hash. + +9. `--session-arg "metadata_mutability:u8='0'"` + + A setting allowing for mutability of metadata. This is only available when using the ordinal identification mode, as the hash mode depends on immutability for identification. In this instance, despite ordinal identification, the 0 represents immutable metadata. + +The session arguments match the available [modalities](../../modalities.md). -- `NETWORK_NAME`: Use the relevant network name -- `PATH_TO_SECRET_KEY`: The path to your secret key -- `AMOUNT`: Gas amount in motes needed for deploy execution -- `WASM_FILE_PATH`: The location of the compiled NFT Wasm file -- `NAME:TYPE='VALUE'`: The required and optional arguments for installing the contract
Expand for a sample query and response @@ -245,29 +275,8 @@ casper-client get-deploy --node-address https://rpc.testnet.casperlabs.io/ [DEPL -### Querying Contract Entry Points - -This step will narrow down the context and check the status of a specific entry point using arguments. - -```bash -casper-client query-global-state --node-address http:// \ ---state-root-hash [STATE_ROOT_HASH] \ ---key [ACCOUNT_HASH] \ --q "[CONTRACT_NAME/ARGUMENT]" -``` +## Next Steps - +- Learn to [Query](./querying-NFTs.md) the NFT contract +- Learn to [Mint, Transfer, and Burn](./interacting-with-NFTs.md) NFT tokens -
-Expand querying the contract name - -```bash -casper-client query-global-state --node-address https://rpc.testnet.casperlabs.io/ \ ---state-root-hash e45cab47e15615cfe27c889b0a6446986077a1d6fb5b6a2be49d230273bc8d5b \ ---key account-hash-5cb74580bcf97d0a7fa034e60b3d2952e0b170ea5162153b1570e8b1ee4ec3f5 \ --q "nft_collection/name" -``` - -
- - diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md new file mode 100644 index 00000000..b21eec45 --- /dev/null +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -0,0 +1,327 @@ +# Interacting with the NFT Contract using the Rust Casper Client + +This document describes how to transfer NFTs on a Casper network using the Casper client. + +## Prerequisites + +- Install the contract using the [Quickstart](./quickstart-guide.md) or the [Full Installation](./full-installation-tutorial.md) tutorials +- Learn to [Query NFT Contracts](./querying-NFTs.md) and save the various hashes and URefs required throughout this document + +## Table of Contents + +1. [Directly Invoking Entrypoints](#directly-invoking-entrypoints) + +2. [Transferring NFTs](#transferring-nfts) + +3. [Approving Another Account](#approving-another-account) + +4. [Minting NFTs](#minting-nfts) + +5. [Burning NFTs](#burning-nfts) + + +## Directly Invoking Entrypoints + +With the release of CEP-78 version 1.1, users that are interacting with a CEP-78 contract that does not use `ReverseLookupMode` should opt out of using the client Wasm files provided as part of the release. Opting out in this situation is recommended, as directly invoking the entrypoints incurs a lower gas cost compared against using the provided client Wasm to invoke the entrypoint. + +You may invoke the `mint`, `transfer` or `burn` entrypoints directly through either the contract package hash or the contract hash directly. + +Specifically in the case of `mint`, there are fewer runtime arguments that must be provided, thereby reducing the total gas cost of minting an NFT. + +
+Example Mint using StoredVersionByHash + +```bash + +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ +--session-package-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ +--session-entry-point "mint" \ +--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" + +``` + +
+ +
+Example Transfer using StoredContractByHash + +Based on the identifier mode for the given contract instance, either the `token_id` runtime argument must be passed in or in the case of the hash identifier mode, the `token_hash` runtime argument. + +```bash + +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ +--session-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ +--session-entry-point "transfer" \ +--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "target_key:key='account-hash-b4782e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ +--session-arg "token_id:u64='0'" + +``` + +
+ +## Transferring NFTs + +The following command invokes the `transfer` entrypoint on your instance of CEP-78, directing it to transfer 10 of the associated NFT tokens to another account. + +```bash +casper-client put-deploy -n http:// \ +// The chain name of the Casper network on which your CEP-78 instance was installed. +--chain-name [CHAIN_NAME] \ +// The local path to your account's secret key. +--secret-key [PATH_TO_SECRET_KEY] \ +// The contract hash of your CEP-78 contract instance. +--session-hash [CEP-78_CONTRACT_HASH] \ +// The name of the entry point you are invoking. +--session-entry-point "transfer" \ +// The account hash of the account to which you are sending CEP-78 tokens. +--session-arg "recipient:key='account-hash-[HASH]" \ +// The amount of CEP-78 tokens you are sending to the receiving account. +--session-arg "amount:u256='10'" \ +// The gas payment you are allotting, in motes. +--payment-amount "10000000000" +``` + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-hash hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180 \ +--session-entry-point "transfer" \ +--session-arg "recipient:key='account-hash-9f81014b9c7406c531ebf0477132283f4eb59143d7903a2fae54358b26cea44b" \ +--session-arg "amount:u256='50'" \ +--payment-amount "10000000000" +``` + +
+ +This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance. + +### Transferring NFTs using Wasm + +Below is an example of a `casper-client` command that uses the `transfer` Wasm to transfer ownership of an NFT from one user to another. + +- `casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 5000000000 -k ~/secret_key.pem --session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm` + +1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` + + The contract hash of the CEP-78 NFT Contract associated with the NFT to be transferred. + +2. `--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` + + The account hash of the user that currently owns the NFT and wishes to transfer it. + +3. `--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'"` + + The account hash of the user that will receive the NFT. + +4. `--session-arg "is_hash_identifier_mode:bool='false'"` + + Argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. + +5. `--session-arg "token_id:u64='0'"` + + The `token_id` of the NFT to be transferred. + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ +--payment-amount 5000000000 \ +-k ~/secret_key.pem \ +--session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm \ +--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'" \ +--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ +--session-arg "is_hash_identifier_mode:bool='false'" \ +--session-arg "token_id:u64='0'" +``` + +
+ +### Invoking the `balance_of` Entry Point + +The following Casper client command invokes the `balance_of` entry point on the `cep78_test_contract`. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +--secret-key [PATH_TO_SECRET_KEY] \ +--session-package-name "cep78_test_contract" \ +--session-entry-point "balance_of" \ +// The contract hash of your CEP-78 contract instance, passed in as an `account-hash-`. +--session-arg "token_contract:account_hash='account-hash-[HASH]'" \ +// The account hash of the account whose balance you are checking. +--session-arg "address:key='account-hash-[HASH]'" \ +--payment-amount 1000000000 +``` + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-package-name "cep78_test_contract" \ +--session-entry-point "balance_of" \ +--session-arg "token_contract:account_hash='account-hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180'" \ +--session-arg "address:key='account-hash-303c0f8208220fe9a4de40e1ada1d35fdd6c678877908f01fddb2a56502d67fd'" \ +--payment-amount 1000000000 +``` + +
+ +## Approving Another Account + +The Casper NFT contract features an `approve` entry point that allows an account to delegate another account to spend a preset number of CEP-78 tokens from their balance. + +The following command approves another account to spend 15 tokens from the balance of the account that installed and owns the CEP-78 contract instance. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +--secret-key [PATH_TO_SECRET_KEY] \ +// The contract hash of the CEP-78 token contract. +--session-hash [CEP-78_CONTRACT_HASH] \ +--session-entry-point "approve" \ +// The account hash of the account that will receive an allowance from the balance of the account that sent the Deploy. +--session-arg "spender:key='account-hash-[HASH]'" \ +// The number of CEP-78 tokens included in the allowance. +--session-arg "amount:u256='15'" \ +--payment-amount "10000000000" +``` + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ +--session-entry-point "approve" \ +--session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ +--session-arg "amount:u256='15'" \ +--payment-amount "10000000000" +``` + +
+ +### Transferring Tokens from an Approved Account + +The following command allows an account to transfer CEP-78 tokens held by another account up to their approved allowance. + +```bash +casper-client put-deploy -n http:// \ +--chain-name [CHAIN_NAME] \ +// The secret key for the account that is spending their allowance from another account's balance. +--secret-key [PATH_TO_SECRET_KEY] \ +// The CEP-78 token contract. +--session-hash [CEP-78_CONTRACT_HASH] \ +--session-entry-point "transfer" \ +// The account hash of the account that holds the CEP-78 in their balance. +--session-arg "owner:key='account-hash-[HASH]'" \ +// The account hash of the account that will receive the transferred CEP-78 tokens. +--session-arg "recipient:key='account-hash-[HASH]'" \ +// The amount of tokens to be transferred. If this amount exceeds the allowance of the account sending the deploy, it will fail. +--session-arg "amount:u256='10'" \ +--payment-amount "10000000000" +``` + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/\ +--chain-name "casper-test" \ +--secret-key ~/KEYS/secret_key.pem \ +--session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ +--session-entry-point "transfer" \ +--session-arg "owner:key='account-hash-39f15c23df9be1244572bb499fac62cbcad3cab2dc1438609842f602f943d7d2'" \ +--session-arg "recipient:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ +--session-arg "amount:u256='10'" \ +--payment-amount "10000000000" +``` +
+ +## Minting NFTs + +Below is an example of a `casper-client` command that uses the `mint` function of the contract to mint an NFT for the user associated with `node-1` in an [NCTL environment](https://docs.casper.network/developers/dapps/nctl-test/). + +- `casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm` + +1. `--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'"` + + The contract hash of the previously installed CEP-78 NFT contract from which we will be minting. + +2. `--session-arg "collection_name:string='cep78_'"` + + The collection name of the previously installed CEP-78 NFT contract from which we will be minting. + +3. `--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` + + The collection name of the NFT to be minted. + +4. `--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'"` + + Metadata describing the NFT to be minted, passed in as a `string`. + + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ +--payment-amount 5000000000 \ +-k ~/KEYS/secret_key.pem \ +--session-entry-point "mint" \ +--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'" \ +--session-arg "collection_name:string='CEP-78-collection'"` \ +--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" +``` + +
+ + +## Burning NFTs + +Below is an example of a `casper-client` command that uses the `burn` entrypoint to burn an NFT within a CEP-78 collection. If this command is used, the NFT in question will no longer be accessible by anyone. + +- `casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 5000000000 -k ~/KEYS/secret_key.pem \` + +1. `--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5` + + The session hash corresponding to the NFT's contract hash. + +2. `--session-entry-point "burn"` + + The entrypoint corresponding to the `burn` function. + +3. `--session-arg "token_id:u64='1'"` + + The token ID for the NFT to be burned. If the `identifier_mode` is not set to `Ordinal`, you must provide the `token_hash` instead. + +
+Casper client command without comments + +```bash +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ +--payment-amount 5000000000 \ +-k ~/KEYS/secret_key.pem \ +--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5 \ +--session-entry-point "burn" \ +--session-arg "token_id:u64='1'" +``` + +
+ +### Next Steps + +- [Testing Framework for CEP-78](./testing-NFTs.md) \ No newline at end of file diff --git a/docs/tutorials/getting started/query.md b/docs/tutorials/getting-started/querying-NFTs.md similarity index 99% rename from docs/tutorials/getting started/query.md rename to docs/tutorials/getting-started/querying-NFTs.md index 24bac9f4..578fba0c 100644 --- a/docs/tutorials/getting started/query.md +++ b/docs/tutorials/getting-started/querying-NFTs.md @@ -397,4 +397,4 @@ casper-client query-global-state -n https://rpc.testnet.casperlabs.io/ \ ## Next Steps -- [NFT Transfers](./transfer.md) \ No newline at end of file +- Learn to [Mint, Transfer, and Burn](./interacting-with-NFTs.md) NFT tokens \ No newline at end of file diff --git a/docs/tutorials/getting started/quickstart-guide.md b/docs/tutorials/getting-started/quickstart-guide.md similarity index 94% rename from docs/tutorials/getting started/quickstart-guide.md rename to docs/tutorials/getting-started/quickstart-guide.md index 549423d2..65eec42b 100644 --- a/docs/tutorials/getting started/quickstart-guide.md +++ b/docs/tutorials/getting-started/quickstart-guide.md @@ -59,6 +59,6 @@ casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ \ Learn to query the contract, perform token transfers, set up approvals, and understand the testing framework. -- [Exploring the NTF Contract](./query.md) -- [NFT Transfers and Allowances](./transfer.md) -- [Testing Framework for CEP-78](./tests.md) \ No newline at end of file +- [Query](./querying-NFTs.md) the NTF Contract +- Learn to [Mint, Transfer, and Burn](./interacting-with-NFTs.md) NFT tokens +- Review the [Tests](./testing-NFTs.md) \ No newline at end of file diff --git a/docs/tutorials/getting started/tests.md b/docs/tutorials/getting-started/testing-NFTs.md similarity index 100% rename from docs/tutorials/getting started/tests.md rename to docs/tutorials/getting-started/testing-NFTs.md diff --git a/docs/using-casper-client.md b/docs/using-casper-client.md deleted file mode 100644 index cf047021..00000000 --- a/docs/using-casper-client.md +++ /dev/null @@ -1,237 +0,0 @@ -# Installing and Interacting with the Contract using the Rust Casper Client - -This documentation will guide you through the process of installing and interacting with an instance of the CEP-78 enhanced NFT standard contract through Casper's Rust CLI client. The contract code installs an instance of CEP-78 as per session arguments provided at the time of installation. It requires a minimum Rust version of `1.63.0`. - -Information on the modalities used throughout this installation process can be found in the [modalities documentation](modalities.md). - -## Table of Contents - -1. [Installing the Contract](#installing-the-contract) - -2. [Directly Invoking Entrypoints](#directly-invoking-entrypoints) - -3. [Minting an NFT](#minting-an-nft) - -4. [Transferring NFTs Between Users](#transferring-nfts-between-users) - -5. [Burning an NFT](#burning-an-nft) - -## Installing the Contract - -Installing the enhanced NFT contract to global state requires the use of a [Deploy](https://docs.casper.network/developers/dapps/sending-deploys/). In this case, the session code can be compiled to Wasm by running the `make build-contract` command provided in the Makefile at the top level. The Wasm will be found in the `contract/target/wasm32-unknown-unknown/release` directory as `contract.wasm`. - -Below is an example of a `casper-client` command that provides all required session arguments to install a valid instance of the CEP-78 contract on global state. - -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 500000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/contract/target/wasm32-unknown-unknown/release/contract.wasm` - -1. `--session-arg "collection_name:string='CEP-78-collection'"` - - The name of the NFT collection as a string. In this instance, "CEP-78-collection". - -2. `--session-arg "collection_symbol:string='CEP78'"` - - The symbol representing the NFT collection as a string. In this instance, "CEP78". - -3. `--session-arg "total_token_supply:u64='100'"` - - The total supply of tokens to be minted. In this instance, 100. If the contract owner is unsure of the total number of NFTs they will require, they should err on the side of caution. - -4. `--session-arg "ownership_mode:u8='2'"` - - The ownership mode for this contract. In this instance the 2 represents "Transferable" mode. Under these conditions, users can freely transfer their NFTs between one another. - -5. `--session-arg "nft_kind:u8='1'"` - - The type of commodity represented by these NFTs. In this instance, the 1 represents a digital collection. - -6. `--session-arg "nft_metadata_kind:u8='0'"` - - The type of metadata used by this contract. In this instance, the 0 represents CEP-78 standard for metadata. - -7. `--session-arg "json_schema:string=''"` - - An empty JSON string, as the contract has awareness of the CEP-78 JSON schema. Using the custom validated modality would require passing through a valid JSON schema for your custom metadata. - -8. `--session-arg "identifier_mode:u8='0'"` - - The mode used to identify individual NFTs. For 0, this means an ordinal identification sequence rather than by hash. - -9. `--session-arg "metadata_mutability:u8='0'"` - - A setting allowing for mutability of metadata. This is only available when using the ordinal identification mode, as the hash mode depends on immutability for identification. In this instance, despite ordinal identification, the 0 represents immutable metadata. - -The session arguments match the available modalities as listed in this [README](https://github.com/casper-ecosystem/cep-78-enhanced-nft). - -
-Casper client command without comments - -```bash -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 500000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/contract/target/wasm32-unknown-unknown/release/contract.wasm \ ---session-arg "collection_name:string='CEP-78-collection'" \ ---session-arg "collection_symbol:string='CEP78'" \ ---session-arg "total_token_supply:u64='100'" \ ---session-arg "ownership_mode:u8='2'" \ ---session-arg "nft_kind:u8='1'" \ ---session-arg "nft_metadata_kind:u8='0'" \ ---session-arg "json_schema:string=''" \ ---session-arg "identifier_mode:u8='0'" \ ---session-arg "metadata_mutability:u8='0'" -``` - -
- -## Directly Invoking Entrypoints - -With the release of CEP-78 version 1.1, users that are interacting with a CEP-78 contract that does not use `ReverseLookupMode` should opt out of using the client Wasms provided as part of the release. Opting out in this situation is recommended, as directly invoking the entrypoints incurs a lower gas cost compared against using the provided client Wasm to invoke the entrypoint. - -You may invoke the `mint`, `transfer` or `burn` entrypoints directly through either the contract package hash or the contract hash directly. - -Specifically in the case of `mint`, there are fewer runtime arguments that must be provided, thereby reducing the total gas cost of minting an NFT. - -
-Example Mint using StoredVersionByHash - -```bash - -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ ---session-package-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ ---session-entry-point "mint" \ ---session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ ---session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" - -``` - -
- -
-Example Transfer using StoredContractByHash - -Based on the identifier mode for the given contract instance, either the `token_id` runtime argument must be passed in or in the case of the hash identifier mode, the `token_hash` runtime argument. - -```bash - -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ ---session-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ ---session-entry-point "transfer" \ ---session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ ---session-arg "target_key:key='account-hash-b4782e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ ---session-arg "token_id:u64='0'" - -``` - -
- -## Minting an NFT - -Below is an example of a `casper-client` command that uses the `mint` function of the contract to mint an NFT for the user associated with `node-1` in an [NCTL environment](https://docs.casper.network/developers/dapps/nctl-test/). - -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm` - -1. `--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'"` - - The contract hash of the previously installed CEP-78 NFT contract from which we will be minting. - -2. `--session-arg "collection_name:string='cep78_'"` - - The collection name of the previously installed CEP-78 NFT contract from which we will be minting. - -3. `--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` - - The collection name of the NFT to be minted. - -4. `--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'"` - - Metadata describing the NFT to be minted, passed in as a `string`. - -
-Casper client command without comments - -```bash - -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ ---payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ ---session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm \ ---session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'" \ ---session-arg "collection_name:string='cep78_'"` \ ---session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ ---session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" - -``` - -
- -## Transferring NFTs Between Users - -Below is an example of a `casper-client` command that uses the `transfer` function to transfer ownership of an NFT from one user to another. In this case, we are transferring the previously minted NFT from the user associated with `node-2` to the user associated with `node-3`. - -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm` - -1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` - - The contract hash of the CEP-78 NFT Contract associated with the NFT to be transferred. - -2. `--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` - - The account hash of the user that currently owns the NFT and wishes to transfer it. - -3. `--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'"` - - The account hash of the user that will receive the NFT. - -4. `--session-arg "is_hash_identifier_mode:bool='false'"` - - Argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. - -5. `--session-arg "token_id:u64='0'"` - - The `token_id` of the NFT to be transferred. - -
-Casper client command without comments - -```bash -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ ---payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ ---session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm \ ---session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'" \ ---session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ ---session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ ---session-arg "is_hash_identifier_mode:bool='false'" \ ---session-arg "token_id:u64='0'" -``` - -
- -## Burning an NFT - -Below is an example of a `casper-client` command that uses the `burn` function to burn an NFT within a CEP-78 collection. If this command is used, the NFT in question will no longer be accessible by anyone. - -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem` - -1. `--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5` - - The session hash corresponding to the NFT's contract hash. - -2. `--session-entry-point "burn"` - - The entrypoint corresponding to the `burn` function. - -3. `--session-arg "token_id:u64='1'"` - - The token ID for the NFT to be burned. If the `identifier_mode` is not set to `Ordinal`, you must provide the `token_hash` instead. - -
-Casper client command without comments - -```bash -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ ---payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ ---session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5 \ ---session-entry-point "burn" \ ---session-arg "token_id:u64='1'" -``` - -
\ No newline at end of file From 6bdf63160073b0260f6d9e122b099b2c1c587ac0 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Thu, 29 Feb 2024 18:11:51 +0100 Subject: [PATCH 12/26] Minor edits --- docs/tutorials/getting-started/interacting-with-NFTs.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index b21eec45..46696f47 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -22,11 +22,11 @@ This document describes how to transfer NFTs on a Casper network using the Caspe ## Directly Invoking Entrypoints -With the release of CEP-78 version 1.1, users that are interacting with a CEP-78 contract that does not use `ReverseLookupMode` should opt out of using the client Wasm files provided as part of the release. Opting out in this situation is recommended, as directly invoking the entrypoints incurs a lower gas cost compared against using the provided client Wasm to invoke the entrypoint. +With the release of CEP-78 version 1.1, users who are interacting with a CEP-78 contract that does not use `ReverseLookupMode` should opt out of using the client Wasm files provided as part of the release. Opting out in this situation is recommended, as directly invoking the entrypoints incurs a lower gas cost compared to using the provided client Wasm to invoke the entrypoint. -You may invoke the `mint`, `transfer` or `burn` entrypoints directly through either the contract package hash or the contract hash directly. +You may invoke the `mint`, `transfer`, or `burn` entrypoints directly through either the contract package hash or the contract hash directly. -Specifically in the case of `mint`, there are fewer runtime arguments that must be provided, thereby reducing the total gas cost of minting an NFT. +In the case of `mint`, fewer runtime arguments must be provided, thereby reducing the total gas cost of minting an NFT.
Example Mint using StoredVersionByHash @@ -46,7 +46,7 @@ casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "cas
Example Transfer using StoredContractByHash -Based on the identifier mode for the given contract instance, either the `token_id` runtime argument must be passed in or in the case of the hash identifier mode, the `token_hash` runtime argument. +Based on the identifier mode for the given contract instance, either the `token_id` runtime argument must be passed in or, in the case of the hash identifier mode, the `token_hash` runtime argument. ```bash From c1c9d0f03855945581275cec2cbf1159a9e7374e Mon Sep 17 00:00:00 2001 From: ipopescu Date: Thu, 29 Feb 2024 19:06:37 +0100 Subject: [PATCH 13/26] Switch back to nctl commands --- README.md | 2 +- docs/tutorials/custom-migration-tutorial.md | 2 +- .../full-installation-tutorial.md | 22 +- .../getting-started/interacting-with-NFTs.md | 204 +++++++++--------- .../getting-started/querying-NFTs.md | 2 +- .../getting-started/quickstart-guide.md | 10 +- docs/tutorials/standard-migration-tutorial.md | 2 +- 7 files changed, 128 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index b9f6e025..21989055 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ The following are the optional parameters that can be passed in at the time of i The following is an example of installing the NFT contract via a deploy using the Rust CLI Casper client. You can find more examples [here](/docs/tutorials/getting-started/full-installation-tutorial.md). ```bash -casper-client put-deploy -n http://65.108.0.148:7777/rpc --chain-name "casper-test" --payment-amount 500000000000 -k keys/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ +casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 500000000000 -k keys/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ --session-arg "collection_name:string='enhanced-nft-1'" \ --session-arg "collection_symbol:string='ENFT-1'" \ --session-arg "total_token_supply:u64='10'" \ diff --git a/docs/tutorials/custom-migration-tutorial.md b/docs/tutorials/custom-migration-tutorial.md index d4d7b94a..d7f672ce 100644 --- a/docs/tutorials/custom-migration-tutorial.md +++ b/docs/tutorials/custom-migration-tutorial.md @@ -85,7 +85,7 @@ The following is an example of upgrading and migrating to version 1.1.1 of a pre ```bash casper-client put-deploy \ ---node-addres http://65.21.235.219:7777 \ +--node-addres https://rpc.testnet.casperlabs.io/ \ --chain-name "casper-test" \ --secret-key ~/KEYS/secret_key.pem \ --payment-amount 300000000000 \ diff --git a/docs/tutorials/getting-started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md index a180c3b3..ef48ac77 100644 --- a/docs/tutorials/getting-started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -26,7 +26,7 @@ Information on the modalities used throughout this installation process can be f Before using this guide, ensure you meet the following requirements: - Set up the [development prerequisites](https://docs.casper.network/developers/prerequisites/), including the [Casper client](https://docs.casper.network/developers/prerequisites/#install-casper-client) -- Get a valid [node address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers), or use the following Testnet node: [https://rpc.testnet.casperlabs.io/](https://rpc.testnet.casperlabs.io/) +- Get a valid [node address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers) from the network - Know how to install a [smart contract](https://docs.casper.network/developers/cli/sending-deploys/) on a Casper network - Hold enough CSPR tokens to pay for transactions @@ -150,7 +150,7 @@ Installing the enhanced NFT contract to global state requires the use of a [Depl This step queries information about the network state given the latest state root hash. You will also need the [IP address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers) from a Testnet peer node. ```bash -casper-client get-state-root-hash --node-address https://rpc.testnet.casperlabs.io/ +casper-client get-state-root-hash --node-address http://localhost:11101/rpc/ ``` ### Querying the Account State @@ -173,9 +173,9 @@ casper-client query-global-state --node-address http:// \ Expand for a sample command ```bash -casper-client query-global-state --node-address https://rpc.testnet.casperlabs.io/ \ ---state-root-hash e45cab47e15615cfe27c889b0a6446986077a1d6fb5b6a2be49d230273bc8d5b \ ---key account-hash-5cb74580bcf97d0a7fa034e60b3d2952e0b170ea5162153b1570e8b1ee4ec3f5 +casper-client query-global-state --node-address http://localhost:11101/rpc/ \ +--state-root-hash 376b18e95312328f212f9966200fa40734e66118cbd34ace0a1ec14eacaea6e6 \ +--key account-hash-82729ae3b368bb2c45d23c05c872c446cbcf32b694f1d9efd3d1ea46cf227a11 ```
@@ -188,7 +188,7 @@ Below is an example of a `casper-client` command that provides all required sess Use the Testnet to understand the exact gas amount required for installation. Refer to the [note about gas prices](https://docs.casper.network/developers/cli/sending-deploys/#a-note-about-gas-price) to understand payment amounts and gas price adjustments. -- `casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 200000000000 --secret-key ~/KEYS/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm` +- `casper-client put-deploy -n http://localhost:11101/rpc/ --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm` 1. `--session-arg "collection_name:string='CEP-78-collection'"` @@ -233,10 +233,10 @@ The session arguments match the available [modalities](../../modalities.md). Expand for a sample query and response ```bash -casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---payment-amount 200000000000 \ ---secret-key ~/KEYS/secret_key.pem \ +casper-client put-deploy --node-address http://localhost:11101/rpc/ \ +--chain-name "casper-net-1" \ +--payment-amount 5000000000 \ +--secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ --session-arg "collection_name:string='CEP-78-collection'" \ --session-arg "collection_symbol:string='CEP78'" \ @@ -270,7 +270,7 @@ This command will output the `deploy_hash`, which can be used in the next step t Verify the sent deploy using the `get-deploy` command. ```bash -casper-client get-deploy --node-address https://rpc.testnet.casperlabs.io/ [DEPLOY_HASH] +casper-client get-deploy --node-address http://localhost:11101/rpc/ [DEPLOY_HASH] ``` diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index 46696f47..f670761e 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -33,7 +33,7 @@ In the case of `mint`, fewer runtime arguments must be provided, thereby reducin ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ +casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ --session-package-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ --session-entry-point "mint" \ --session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ @@ -50,7 +50,7 @@ Based on the identifier mode for the given contract instance, either the `token_ ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ +casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ --session-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ --session-entry-point "transfer" \ --session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ @@ -61,51 +61,95 @@ casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "cas
-## Transferring NFTs +## Minting NFTs using Wasm + +Below is an example of a `casper-client` command that uses the `mint` entrypoint of the contract to mint an NFT for the user associated with `node-1` in an [NCTL environment](https://docs.casper.network/developers/dapps/nctl-test/). + +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm` + +1. `--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'"` + + The contract hash of the previously installed CEP-78 NFT contract from which we will be minting. + +2. `--session-arg "collection_name:string='cep78_'"` + + The collection name of the previously installed CEP-78 NFT contract from which we will be minting. + +3. `--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` + + The collection name of the NFT to be minted. -The following command invokes the `transfer` entrypoint on your instance of CEP-78, directing it to transfer 10 of the associated NFT tokens to another account. +4. `--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'"` + + Metadata describing the NFT to be minted, passed in as a `string`. + + +
+Casper client command without comments ```bash -casper-client put-deploy -n http:// \ -// The chain name of the Casper network on which your CEP-78 instance was installed. ---chain-name [CHAIN_NAME] \ -// The local path to your account's secret key. ---secret-key [PATH_TO_SECRET_KEY] \ -// The contract hash of your CEP-78 contract instance. ---session-hash [CEP-78_CONTRACT_HASH] \ -// The name of the entry point you are invoking. ---session-entry-point "transfer" \ -// The account hash of the account to which you are sending CEP-78 tokens. ---session-arg "recipient:key='account-hash-[HASH]" \ -// The amount of CEP-78 tokens you are sending to the receiving account. ---session-arg "amount:u256='10'" \ -// The gas payment you are allotting, in motes. ---payment-amount "10000000000" +casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ +--payment-amount 5000000000 \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm \ +--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'" \ +--session-arg "collection_name:string='cep78_'"` \ +--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" ``` +
+ +## Transferring NFTs + +Below is an example of a `casper-client` command that uses the `transfer` entrypoint to transfer ownership of an NFT from one user to another. In this case, the command transfers a previously minted NFT from the user associated with `node-2` to the user associated with `node-3`. + +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-entry-point "transfer"` + +1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` + + The contract hash of the CEP-78 NFT Contract associated with the NFT to be transferred. + +2. `--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` + + The account hash of the user that currently owns the NFT and wishes to transfer it. + +3. `--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'"` + + The account hash of the user that will receive the NFT. + +4. `--session-arg "is_hash_identifier_mode:bool='false'"` + + Argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. + +5. `--session-arg "token_id:u64='0'"` + + The `token_id` of the NFT to be transferred. +
Casper client command without comments ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-hash hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180 \ +casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ +--payment-amount 5000000000 \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ --session-entry-point "transfer" \ ---session-arg "recipient:key='account-hash-9f81014b9c7406c531ebf0477132283f4eb59143d7903a2fae54358b26cea44b" \ ---session-arg "amount:u256='50'" \ ---payment-amount "10000000000" +--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'" \ +--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ +--session-arg "is_hash_identifier_mode:bool='false'" \ +--session-arg "token_id:u64='0'" ```
-This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance. +This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance as shown [below](#invoking-the-balance_of-entry-point). ### Transferring NFTs using Wasm Below is an example of a `casper-client` command that uses the `transfer` Wasm to transfer ownership of an NFT from one user to another. -- `casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 5000000000 -k ~/secret_key.pem --session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm` +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/secret_key.pem --session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm` 1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` @@ -131,10 +175,10 @@ Below is an example of a `casper-client` command that uses the `transfer` Wasm t Casper client command without comments ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ +casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 5000000000 \ --k ~/secret_key.pem \ ---session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ +--session-entry-point "transfer" \ --session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'" \ --session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ --session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ @@ -165,14 +209,14 @@ casper-client put-deploy -n http:// \ Casper client command without comments ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ +casper-client put-deploy -n http://localhost:11101/rpc/ \ +--chain-name "casper-net-1" \ +--payment-amount 5000000000 \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ --session-package-name "cep78_test_contract" \ --session-entry-point "balance_of" \ --session-arg "token_contract:account_hash='account-hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180'" \ --session-arg "address:key='account-hash-303c0f8208220fe9a4de40e1ada1d35fdd6c678877908f01fddb2a56502d67fd'" \ ---payment-amount 1000000000 ```
@@ -201,92 +245,60 @@ casper-client put-deploy -n http:// \ Casper client command without comments ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ +casper-client put-deploy -n http://localhost:11101/rpc/ \ +--chain-name "casper-net-1" \ +--payment-amount 5000000000 \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ --session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ --session-entry-point "approve" \ --session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ ---session-arg "amount:u256='15'" \ ---payment-amount "10000000000" +--session-arg "amount:u256='15'" ``` ### Transferring Tokens from an Approved Account -The following command allows an account to transfer CEP-78 tokens held by another account up to their approved allowance. - -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ -// The secret key for the account that is spending their allowance from another account's balance. ---secret-key [PATH_TO_SECRET_KEY] \ -// The CEP-78 token contract. ---session-hash [CEP-78_CONTRACT_HASH] \ ---session-entry-point "transfer" \ -// The account hash of the account that holds the CEP-78 in their balance. ---session-arg "owner:key='account-hash-[HASH]'" \ -// The account hash of the account that will receive the transferred CEP-78 tokens. ---session-arg "recipient:key='account-hash-[HASH]'" \ -// The amount of tokens to be transferred. If this amount exceeds the allowance of the account sending the deploy, it will fail. ---session-arg "amount:u256='10'" \ ---payment-amount "10000000000" -``` - -
-Casper client command without comments - -```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/\ ---chain-name "casper-test" \ ---secret-key ~/KEYS/secret_key.pem \ ---session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ ---session-entry-point "transfer" \ ---session-arg "owner:key='account-hash-39f15c23df9be1244572bb499fac62cbcad3cab2dc1438609842f602f943d7d2'" \ ---session-arg "recipient:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ ---session-arg "amount:u256='10'" \ ---payment-amount "10000000000" -``` -
+The following command allows an account to transfer CEP-78 tokens held by another account up to their approved allowance. The command is similar to the transfer example above. -## Minting NFTs +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-entry-point "transfer"` -Below is an example of a `casper-client` command that uses the `mint` function of the contract to mint an NFT for the user associated with `node-1` in an [NCTL environment](https://docs.casper.network/developers/dapps/nctl-test/). +1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` -- `casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm` + The contract hash of the CEP-78 NFT Contract associated with the NFT to be transferred. -1. `--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'"` +2. `--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` - The contract hash of the previously installed CEP-78 NFT contract from which we will be minting. + The account hash of the user that currently owns the NFT and wishes to transfer it. -2. `--session-arg "collection_name:string='cep78_'"` +3. `--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'"` - The collection name of the previously installed CEP-78 NFT contract from which we will be minting. + The account hash of the user that will receive the NFT. -3. `--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` +4. `--session-arg "is_hash_identifier_mode:bool='false'"` - The collection name of the NFT to be minted. + Argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. -4. `--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'"` +5. `--session-arg "token_id:u64='0'"` - Metadata describing the NFT to be minted, passed in as a `string`. + The `token_id` of the NFT to be transferred.
Casper client command without comments ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ +casper-client put-deploy -n http://localhost:11101/rpc/ \ +--chain-name "casper-net-1" \ --payment-amount 5000000000 \ --k ~/KEYS/secret_key.pem \ ---session-entry-point "mint" \ ---session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'" \ ---session-arg "collection_name:string='CEP-78-collection'"` \ ---session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ ---session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ +--session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ +--session-entry-point "transfer" \ +--session-arg "owner:key='account-hash-39f15c23df9be1244572bb499fac62cbcad3cab2dc1438609842f602f943d7d2'" \ +--session-arg "recipient:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ +--session-arg "amount:u256='10'" \ +--payment-amount "10000000000" ``` -
@@ -294,7 +306,7 @@ casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "cas Below is an example of a `casper-client` command that uses the `burn` entrypoint to burn an NFT within a CEP-78 collection. If this command is used, the NFT in question will no longer be accessible by anyone. -- `casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" --payment-amount 5000000000 -k ~/KEYS/secret_key.pem \` +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem` 1. `--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5` @@ -312,9 +324,9 @@ Below is an example of a `casper-client` command that uses the `burn` entrypoint Casper client command without comments ```bash -casper-client put-deploy -n https://rpc.testnet.casperlabs.io/ --chain-name "casper-test" \ +casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 5000000000 \ --k ~/KEYS/secret_key.pem \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ --session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5 \ --session-entry-point "burn" \ --session-arg "token_id:u64='1'" diff --git a/docs/tutorials/getting-started/querying-NFTs.md b/docs/tutorials/getting-started/querying-NFTs.md index 578fba0c..5c72b7e7 100644 --- a/docs/tutorials/getting-started/querying-NFTs.md +++ b/docs/tutorials/getting-started/querying-NFTs.md @@ -30,7 +30,7 @@ casper-client query-global-state -n http:// \ Casper client command without comments ```bash -casper-client query-global-state -n https://rpc.testnet.casperlabs.io/ \ +casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ --key hash-30767a108fedcb8872a0cec5eabb76f743f1bf3bbac9cac6e9c15355ae17d61a \ --state-root-hash ca9ad2c99188cdbb8ceeccff16c6225b53b8c2e01dff945fb7ff3e33b427faf5 ``` diff --git a/docs/tutorials/getting-started/quickstart-guide.md b/docs/tutorials/getting-started/quickstart-guide.md index 65eec42b..cb5bbe5e 100644 --- a/docs/tutorials/getting-started/quickstart-guide.md +++ b/docs/tutorials/getting-started/quickstart-guide.md @@ -9,7 +9,7 @@ For greater detail into the creation and mechanics of the Casper NFT contract, s Before using this guide, ensure you meet the following requirements: - Set up the [development prerequisites](https://docs.casper.network/developers/prerequisites/), including the [Casper client](https://docs.casper.network/developers/prerequisites/#install-casper-client) -- Get a valid [node address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers), or use the following Testnet node: [https://rpc.testnet.casperlabs.io/](https://rpc.testnet.casperlabs.io/) +- Get a valid [node address](https://docs.casper.network/developers/prerequisites/#acquire-node-address-from-network-peers) from the network - Know how to install a [smart contract](https://docs.casper.network/developers/cli/sending-deploys/) on a Casper network - Hold enough CSPR tokens to pay for transactions @@ -39,10 +39,10 @@ test result: ok. 159 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fi The following command will install a sample NFT contract on the Testnet: ```bash -casper-client put-deploy --node-address https://rpc.testnet.casperlabs.io/ \ ---chain-name "casper-test" \ ---payment-amount 200000000000 \ ---secret-key ~/KEYS/secret_key.pem \ +casper-client put-deploy --node-address http://localhost:11101/rpc/ \ +--chain-name "casper-net-1" \ +--payment-amount 5000000000 \ +--secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ --session-arg "collection_name:string='CEP-78-collection'" \ --session-arg "collection_symbol:string='CEP78'" \ diff --git a/docs/tutorials/standard-migration-tutorial.md b/docs/tutorials/standard-migration-tutorial.md index 07135a2b..b321b538 100644 --- a/docs/tutorials/standard-migration-tutorial.md +++ b/docs/tutorials/standard-migration-tutorial.md @@ -86,7 +86,7 @@ The following is an example of upgrading and migrating to version 1.1.1 of a pre ```bash casper-client put-deploy \ ---node-addres http://65.21.235.219:7777 \ +--node-addres https://rpc.testnet.casperlabs.io/ \ --chain-name "casper-test" \ --secret-key ~/KEYS/secret_key.pem \ --payment-amount 300000000000 \ From 5abe955d4a175aefd9009a29f397eb453a60a71f Mon Sep 17 00:00:00 2001 From: ipopescu Date: Thu, 29 Feb 2024 23:48:03 +0100 Subject: [PATCH 14/26] Updated commands after testing --- .../full-installation-tutorial.md | 1264 ++++++++++++++++- .../getting-started/interacting-with-NFTs.md | 194 +-- .../getting-started/querying-NFTs.md | 272 +++- 3 files changed, 1562 insertions(+), 168 deletions(-) diff --git a/docs/tutorials/getting-started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md index ef48ac77..5309657a 100644 --- a/docs/tutorials/getting-started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -158,7 +158,7 @@ casper-client get-state-root-hash --node-address http://localhost:11101/rpc/ Run the following command and supply the path to your public key in hexadecimal format to get the account hash if you don't have it already. ```bash -casper-client account-address --public-key "[PATH_TO_PUBLIC_KEY_HEX]" +casper-client account-address --public-key [PATH_TO_PUBLIC_KEY_HEX] ``` Use the command below to query the state of your account. @@ -170,7 +170,7 @@ casper-client query-global-state --node-address http:// \ ```
-Expand for a sample command +Expand for a sample query and response ```bash casper-client query-global-state --node-address http://localhost:11101/rpc/ \ @@ -178,9 +178,37 @@ casper-client query-global-state --node-address http://localhost:11101/rpc/ \ --key account-hash-82729ae3b368bb2c45d23c05c872c446cbcf32b694f1d9efd3d1ea46cf227a11 ``` +```json +{ + "jsonrpc": "2.0", + "id": -6733022256306802125, + "result": { + "api_version": "1.5.6", + "block_header": null, + "stored_value": { + "Account": { + "account_hash": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "named_keys": [], + "main_purse": "uref-11e6fc5354f61a004df98482376c45964b8b1557e8f2f13fb5f3adab5faa8be1-007", + "associated_keys": [ + { + "account_hash": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "weight": 1 + } + ], + "action_thresholds": { + "deployment": 1, + "key_management": 1 + } + } + }, + "merkle_proof": "[32706 hex chars]" + } +} +``` +
- ### Sending the Installation Deploy @@ -188,7 +216,7 @@ Below is an example of a `casper-client` command that provides all required sess Use the Testnet to understand the exact gas amount required for installation. Refer to the [note about gas prices](https://docs.casper.network/developers/cli/sending-deploys/#a-note-about-gas-price) to understand payment amounts and gas price adjustments. -- `casper-client put-deploy -n http://localhost:11101/rpc/ --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm` +- `casper-client put-deploy -n http://localhost:11101/rpc/ --chain-name "casper-net-1" --payment-amount 500000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm` 1. `--session-arg "collection_name:string='CEP-78-collection'"` @@ -235,7 +263,7 @@ The session arguments match the available [modalities](../../modalities.md). ```bash casper-client put-deploy --node-address http://localhost:11101/rpc/ \ --chain-name "casper-net-1" \ ---payment-amount 5000000000 \ +--payment-amount 500000000000 \ --secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ --session-path contract/target/wasm32-unknown-unknown/release/contract.wasm \ --session-arg "collection_name:string='CEP-78-collection'" \ @@ -253,11 +281,11 @@ This command will output the `deploy_hash`, which can be used in the next step t ```bash { - "id": 931694842944790108, "jsonrpc": "2.0", + "id": 3104428017957320684, "result": { - "api_version": "1.4.3", - "deploy_hash": "b00E59f8aBA5c7aB9...." + "api_version": "1.0.0", + "deploy_hash": "2b084bdccbaaae2b9c6e4de2f5a6cdf06c72f0d02eaeb7d681a29ebdbe3c92b7" } } ``` @@ -273,10 +301,1226 @@ Verify the sent deploy using the `get-deploy` command. casper-client get-deploy --node-address http://localhost:11101/rpc/ [DEPLOY_HASH] ``` - +
+Expand for sample deploy details + +```json +{ + "jsonrpc": "2.0", + "id": -7282936875867676694, + "result": { + "api_version": "1.5.6", + "deploy": { + "hash": "1d1f66b26eb648b5f15bc958a552036e8521b508706056817b0d41c71f6d7afe", + "header": { + "account": "0154d828baafa6858b92919c4d78f26747430dcbecb9aa03e8b44077dc6266cabf", + "timestamp": "2024-02-29T18:28:16.104Z", + "ttl": "30m", + "gas_price": 1, + "body_hash": "90866126c3dbb9a27f672307102bf651663934ee34715d46f9f02caa70226743", + "dependencies": [], + "chain_name": "casper-test" + }, + "payment": { + "ModuleBytes": { + "module_bytes": "", + "args": [ + [ + "amount", + { + "cl_type": "U512", + "bytes": "050088526a74", + "parsed": "500000000000" + } + ] + ] + } + }, + "session": { + "ModuleBytes": { + "module_bytes": "[621680 hex chars]", + "args": [ + [ + "collection_name", + { + "cl_type": "String", + "bytes": "120000004345502d37382d636f6c6c656374696f6e32", + "parsed": "CEP-78-collection" + } + ], + [ + "collection_symbol", + { + "cl_type": "String", + "bytes": "050000004345503738", + "parsed": "CEP78" + } + ], + [ + "total_token_supply", + { + "cl_type": "U64", + "bytes": "6400000000000000", + "parsed": 100 + } + ], + [ + "ownership_mode", + { + "cl_type": "U8", + "bytes": "02", + "parsed": 2 + } + ], + [ + "nft_kind", + { + "cl_type": "U8", + "bytes": "01", + "parsed": 1 + } + ], + [ + "nft_metadata_kind", + { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + ], + [ + "json_schema", + { + "cl_type": "String", + "bytes": "0a0000006e66742d736368656d61", + "parsed": "nft-schema" + } + ], + [ + "identifier_mode", + { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + ], + [ + "metadata_mutability", + { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + ] + ] + } + }, + "approvals": [ + { + "signer": "0154d828baafa6858b92919c4d78f26747430dcbecb9aa03e8b44077dc6266cabf", + "signature": "01f866dd88fd179fd214262d0451a92be2673e6d4095eb79beef9e5b8bbbc18862e76c3085dcb1b1ae669a185cb80d94c5084325913b8118338645952bb5ee2200" + } + ] + }, + "execution_results": [ + { + "block_hash": "dca9ff6e9ad7baeead715504dee098069f30dbb9975730be3d3926ab1c58f332", + "result": { + "Success": { + "effect": { + "operations": [], + "transforms": [ + { + "key": "account-hash-6174cf2e6f8fed1715c9a3bace9c50bfe572eecb763b0ed3f644532616452008", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "hash-624dbe2395b9d9503fbee82162f1714ebff6b639f96d2084d26d944c354ec4c5", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "hash-010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7", + "transform": "Identity" + }, + { + "key": "hash-9824d60dc3a5c44a20b9fd260a412437933835b52fc683d8ae36e4ec2114843e", + "transform": "Identity" + }, + { + "key": "hash-010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7", + "transform": "Identity" + }, + { + "key": "balance-11e6fc5354f61a004df98482376c45964b8b1557e8f2f13fb5f3adab5faa8be1", + "transform": "Identity" + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": "Identity" + }, + { + "key": "balance-11e6fc5354f61a004df98482376c45964b8b1557e8f2f13fb5f3adab5faa8be1", + "transform": { + "WriteCLValue": { + "cl_type": "U512", + "bytes": "05c2d627778f", + "parsed": "616179422914" + } + } + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": { + "AddUInt512": "500000000000" + } + }, + { + "key": "uref-e42cd3ae8b4bd60306a72f0f4e9faa4e114e2e2cce5db03bfdd109a8db888e14-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30", + "transform": "WriteContractPackage" + }, + { + "key": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "transform": { + "AddKeys": [ + { + "name": "cep78_contract_package_CEP-78-collection", + "key": "hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30" + } + ] + } + }, + { + "key": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "transform": { + "AddKeys": [ + { + "name": "cep78_contract_package_access_CEP-78-collection", + "key": "uref-e42cd3ae8b4bd60306a72f0f4e9faa4e114e2e2cce5db03bfdd109a8db888e14-007" + } + ] + } + }, + { + "key": "hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30", + "transform": "Identity" + }, + { + "key": "hash-845d3d08e29642afba35704bcb6e38f3c40f1469763bff7a88674c9a5be3f01b", + "transform": "WriteContractWasm" + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": "WriteContract" + }, + { + "key": "hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30", + "transform": "WriteContractPackage" + }, + { + "key": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "transform": { + "AddKeys": [ + { + "name": "cep78_contract_hash_CEP-78-collection", + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796" + } + ] + } + }, + { + "key": "uref-0545c60c0a55e4d8a10fe0c3b2d356150b082e2243b6795b34f67643e4ca13d0-000", + "transform": { + "WriteCLValue": { + "cl_type": "U32", + "bytes": "01000000", + "parsed": 1 + } + } + }, + { + "key": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "transform": { + "AddKeys": [ + { + "name": "cep78_contract_version_CEP-78-collection", + "key": "uref-0545c60c0a55e4d8a10fe0c3b2d356150b082e2243b6795b34f67643e4ca13d0-007" + } + ] + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": "Identity" + }, + { + "key": "hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30", + "transform": "Identity" + }, + { + "key": "hash-845d3d08e29642afba35704bcb6e38f3c40f1469763bff7a88674c9a5be3f01b", + "transform": "Identity" + }, + { + "key": "uref-5aed76a73089e7e32f6fbf5d9a9597843215d4810cd5822c0f5c6e65a0bbb7a3-000", + "transform": { + "WriteCLValue": { + "cl_type": "String", + "bytes": "120000004345502d37382d636f6c6c656374696f6e32", + "parsed": "CEP-78-collection" + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "collection_name", + "key": "uref-5aed76a73089e7e32f6fbf5d9a9597843215d4810cd5822c0f5c6e65a0bbb7a3-007" + } + ] + } + }, + { + "key": "uref-ba4247cc0354644474758d1292924c5115c61c8012cae3f094a91060d9dff779-000", + "transform": { + "WriteCLValue": { + "cl_type": "String", + "bytes": "050000004345503738", + "parsed": "CEP78" + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "collection_symbol", + "key": "uref-ba4247cc0354644474758d1292924c5115c61c8012cae3f094a91060d9dff779-007" + } + ] + } + }, + { + "key": "uref-e5f06deadcbfe5a469e7c162346580744746bfdc0ec67002e0ecba5b11096827-000", + "transform": { + "WriteCLValue": { + "cl_type": "U64", + "bytes": "6400000000000000", + "parsed": 100 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "total_token_supply", + "key": "uref-e5f06deadcbfe5a469e7c162346580744746bfdc0ec67002e0ecba5b11096827-007" + } + ] + } + }, + { + "key": "uref-89711af74265427dc65d7c5a421cedde82de69d192cad36f34efa36504108572-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "02", + "parsed": 2 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "ownership_mode", + "key": "uref-89711af74265427dc65d7c5a421cedde82de69d192cad36f34efa36504108572-007" + } + ] + } + }, + { + "key": "uref-e02c29a6120d5da7f14fb664ca60c3ade56a3171a670c292d0a4ea0f9ae4f0c8-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "01", + "parsed": 1 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "nft_kind", + "key": "uref-e02c29a6120d5da7f14fb664ca60c3ade56a3171a670c292d0a4ea0f9ae4f0c8-007" + } + ] + } + }, + { + "key": "uref-772103052d4559fcc2f8f2c2568eb75214462d463009106938e6f20e1cc0a7c0-000", + "transform": { + "WriteCLValue": { + "cl_type": "String", + "bytes": "0a0000006e66742d736368656d61", + "parsed": "nft-schema" + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "json_schema", + "key": "uref-772103052d4559fcc2f8f2c2568eb75214462d463009106938e6f20e1cc0a7c0-007" + } + ] + } + }, + { + "key": "uref-3b45a30c98d90de2c62812c6689aa2fac0cb4d08772fcfdee0584c5db2b1d12a-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "minting_mode", + "key": "uref-3b45a30c98d90de2c62812c6689aa2fac0cb4d08772fcfdee0584c5db2b1d12a-007" + } + ] + } + }, + { + "key": "uref-8443151d736bb3268815ad7848708d44ccc661799f969697c64b1cddb5ce89a7-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "02", + "parsed": 2 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "holder_mode", + "key": "uref-8443151d736bb3268815ad7848708d44ccc661799f969697c64b1cddb5ce89a7-007" + } + ] + } + }, + { + "key": "uref-a77f2ac1f5e72c6b096ca414ae2c986a5387442ddf8e89a35b787a756adc4bb4-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "whitelist_mode", + "key": "uref-a77f2ac1f5e72c6b096ca414ae2c986a5387442ddf8e89a35b787a756adc4bb4-007" + } + ] + } + }, + { + "key": "uref-1ec63ea6442d9b4ef40d926280f8b72704b763d3ef7cdaccd9ecb04af5562d99-000", + "transform": { + "WriteCLValue": { + "cl_type": "String", + "bytes": "1800000063657037385f4345502d37382d636f6c6c656374696f6e32", + "parsed": "cep78_CEP-78-collection" + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "receipt_name", + "key": "uref-1ec63ea6442d9b4ef40d926280f8b72704b763d3ef7cdaccd9ecb04af5562d99-007" + } + ] + } + }, + { + "key": "uref-ac99c07d666f45ff5c86a2c1bb6cc44b612ddd5d39a9de88045b441ff6e6b327-000", + "transform": { + "WriteCLValue": { + "cl_type": "String", + "bytes": "[170 hex chars]", + "parsed": "contract-package-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30" + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "cep78_CEP-78-collection", + "key": "uref-ac99c07d666f45ff5c86a2c1bb6cc44b612ddd5d39a9de88045b441ff6e6b327-007" + } + ] + } + }, + { + "key": "uref-45e1bc671353ae58c41a703055959da243deefc7f4c3f121f3f9828d97475bda-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "nft_metadata_kind", + "key": "uref-45e1bc671353ae58c41a703055959da243deefc7f4c3f121f3f9828d97475bda-007" + } + ] + } + }, + { + "key": "uref-05c0eb8e7ef4caa6f228e8ee91874dc64926b95926d839b458fdce356063a817-000", + "transform": { + "WriteCLValue": { + "cl_type": { + "Map": { + "key": "U8", + "value": "U8" + } + }, + "bytes": "010000000000", + "parsed": [ + { + "key": 0, + "value": 0 + } + ] + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "nft_metadata_kinds", + "key": "uref-05c0eb8e7ef4caa6f228e8ee91874dc64926b95926d839b458fdce356063a817-007" + } + ] + } + }, + { + "key": "uref-f53ea99b60ae6d046a6fb0d996475714ef03ed33b39674a8fe016c8324116baf-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "identifier_mode", + "key": "uref-f53ea99b60ae6d046a6fb0d996475714ef03ed33b39674a8fe016c8324116baf-007" + } + ] + } + }, + { + "key": "uref-2ca963a70a69df2db931b8761b4de13bd22e2fc54a415b0b57d4204c9b90dde9-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "metadata_mutability", + "key": "uref-2ca963a70a69df2db931b8761b4de13bd22e2fc54a415b0b57d4204c9b90dde9-007" + } + ] + } + }, + { + "key": "uref-eb1a7f69592881587805fde2d53e8e5b3dcbabd81311faa7b9d19ea731f83d9b-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "burn_mode", + "key": "uref-eb1a7f69592881587805fde2d53e8e5b3dcbabd81311faa7b9d19ea731f83d9b-007" + } + ] + } + }, + { + "key": "uref-f226eed9d0c5fcf58e6b481d45417721e35435c2ef5eb4d26d215209149438ba-000", + "transform": { + "WriteCLValue": { + "cl_type": "Bool", + "bytes": "00", + "parsed": false + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "operator_burn_mode", + "key": "uref-f226eed9d0c5fcf58e6b481d45417721e35435c2ef5eb4d26d215209149438ba-007" + } + ] + } + }, + { + "key": "uref-51acad53fd1a6ce6a52cf83ed7f921565311ed86cd362969bacf9457b6bf5c1a-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "events_mode", + "key": "uref-51acad53fd1a6ce6a52cf83ed7f921565311ed86cd362969bacf9457b6bf5c1a-007" + } + ] + } + }, + { + "key": "uref-dca79aa4244d0123ad52799fc4f922b2ae9fc023c9e56f999979f535a792eef5-000", + "transform": { + "WriteCLValue": { + "cl_type": "Bool", + "bytes": "01", + "parsed": true + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "allow_minting", + "key": "uref-dca79aa4244d0123ad52799fc4f922b2ae9fc023c9e56f999979f535a792eef5-007" + } + ] + } + }, + { + "key": "uref-f86e2c4057cc17d93593fb203a923d67e5bc68e6428a6d94f6eab0c35450653d-000", + "transform": { + "WriteCLValue": { + "cl_type": "U64", + "bytes": "0000000000000000", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "number_of_minted_tokens", + "key": "uref-f86e2c4057cc17d93593fb203a923d67e5bc68e6428a6d94f6eab0c35450653d-007" + } + ] + } + }, + { + "key": "uref-ff53b7094bcb6659b558d31fdf63f837b05c0ee6030bfe18ad4c3fb0462b9b17-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "token_owners", + "key": "uref-ff53b7094bcb6659b558d31fdf63f837b05c0ee6030bfe18ad4c3fb0462b9b17-007" + } + ] + } + }, + { + "key": "uref-5700d04b36eb1f50204c0d1d05c8ed6aae77eaeaa8a425c78f5a24cbae2e4d26-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "token_issuers", + "key": "uref-5700d04b36eb1f50204c0d1d05c8ed6aae77eaeaa8a425c78f5a24cbae2e4d26-007" + } + ] + } + }, + { + "key": "uref-76aac8f7224c5c1624b4255fff59ecc8ee2c7a1ba460b4f70945d7548abbffd0-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "approved", + "key": "uref-76aac8f7224c5c1624b4255fff59ecc8ee2c7a1ba460b4f70945d7548abbffd0-007" + } + ] + } + }, + { + "key": "uref-ff8ad952307b57a051ef6cb597a55cc2007e587c575584addf6a6fc12c0efd7b-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "operators", + "key": "uref-ff8ad952307b57a051ef6cb597a55cc2007e587c575584addf6a6fc12c0efd7b-007" + } + ] + } + }, + { + "key": "uref-0c144d231ac070adb2668f2a9f3d0eba32c7468efa879f0f29c832c63698966b-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "burnt_tokens", + "key": "uref-0c144d231ac070adb2668f2a9f3d0eba32c7468efa879f0f29c832c63698966b-007" + } + ] + } + }, + { + "key": "uref-3d271bac2030ddee54bf4ea92b9b854d800a10a0df5d6e328a045be19af27538-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "balances", + "key": "uref-3d271bac2030ddee54bf4ea92b9b854d800a10a0df5d6e328a045be19af27538-007" + } + ] + } + }, + { + "key": "uref-575108b0258e92ebede1e50345b608d42963bdac24379022be20b76cfde15301-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "metadata_custom_validated", + "key": "uref-575108b0258e92ebede1e50345b608d42963bdac24379022be20b76cfde15301-007" + } + ] + } + }, + { + "key": "uref-2c2176a9efd465d2e4d5de05d75d029e03040d0a5668c4e08facb0cd3442d30a-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "metadata_cep78", + "key": "uref-2c2176a9efd465d2e4d5de05d75d029e03040d0a5668c4e08facb0cd3442d30a-007" + } + ] + } + }, + { + "key": "uref-eb37c0fe3b53fa5c72b02976f2840b7bf3692954fc830f8a10dc538d0c506e63-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "metadata_nft721", + "key": "uref-eb37c0fe3b53fa5c72b02976f2840b7bf3692954fc830f8a10dc538d0c506e63-007" + } + ] + } + }, + { + "key": "uref-cdb17062423b769a7b0bc18fe0a2202b68d2ba77786291018a24fd53f4532ab8-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "metadata_raw", + "key": "uref-cdb17062423b769a7b0bc18fe0a2202b68d2ba77786291018a24fd53f4532ab8-007" + } + ] + } + }, + { + "key": "uref-e280dd23c847724422543b0d70f1ed4c95c8da9e1a71927ae39add652859775c-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "hash_by_index", + "key": "uref-e280dd23c847724422543b0d70f1ed4c95c8da9e1a71927ae39add652859775c-007" + } + ] + } + }, + { + "key": "uref-6299c9322631f374fc1a5e20920641b23f437a3c0ba8da22cc23cba11b0fa3a5-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "index_by_hash", + "key": "uref-6299c9322631f374fc1a5e20920641b23f437a3c0ba8da22cc23cba11b0fa3a5-007" + } + ] + } + }, + { + "key": "uref-00efcfa874a60b5b615b3c6d781cf69c3559b5372d15457fe4a3bb6d07c66acd-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "page_table", + "key": "uref-00efcfa874a60b5b615b3c6d781cf69c3559b5372d15457fe4a3bb6d07c66acd-007" + } + ] + } + }, + { + "key": "uref-77b5861bdc04f3c63417dd2ed1943f659f6180603982a24587f79cbc38801cf4-000", + "transform": { + "WriteCLValue": { + "cl_type": "Unit", + "bytes": "", + "parsed": null + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "acl_whitelist", + "key": "uref-77b5861bdc04f3c63417dd2ed1943f659f6180603982a24587f79cbc38801cf4-007" + } + ] + } + }, + { + "key": "uref-5e950cdd5497633c1d03284ec6e70ce436744cc172d6e26e21e4e474d1b34312-000", + "transform": { + "WriteCLValue": { + "cl_type": "Bool", + "bytes": "00", + "parsed": false + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "acl_package_mode", + "key": "uref-5e950cdd5497633c1d03284ec6e70ce436744cc172d6e26e21e4e474d1b34312-007" + } + ] + } + }, + { + "key": "uref-05c2868f179f6b2323f1d4ea069858956c9666d14073748aae4a748d27a8a894-000", + "transform": { + "WriteCLValue": { + "cl_type": "Bool", + "bytes": "00", + "parsed": false + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "package_operator_mode", + "key": "uref-05c2868f179f6b2323f1d4ea069858956c9666d14073748aae4a748d27a8a894-007" + } + ] + } + }, + { + "key": "uref-4d851152d7b89dff805dcf6eb61a33870dab9345084a5874575476a584d71b83-000", + "transform": { + "WriteCLValue": { + "cl_type": "U8", + "bytes": "00", + "parsed": 0 + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "reporting_mode", + "key": "uref-4d851152d7b89dff805dcf6eb61a33870dab9345084a5874575476a584d71b83-007" + } + ] + } + }, + { + "key": "uref-2e3b8aafb27aae47c9b7d3728d20d8815b706e2245c23b84f0e712cd1d1e9124-000", + "transform": { + "WriteCLValue": { + "cl_type": "Bool", + "bytes": "00", + "parsed": false + } + } + }, + { + "key": "hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796", + "transform": { + "AddKeys": [ + { + "name": "rlo_mflag", + "key": "uref-2e3b8aafb27aae47c9b7d3728d20d8815b706e2245c23b84f0e712cd1d1e9124-007" + } + ] + } + }, + { + "key": "deploy-1d1f66b26eb648b5f15bc958a552036e8521b508706056817b0d41c71f6d7afe", + "transform": { + "WriteDeployInfo": { + "deploy_hash": "1d1f66b26eb648b5f15bc958a552036e8521b508706056817b0d41c71f6d7afe", + "transfers": [], + "from": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "source": "uref-11e6fc5354f61a004df98482376c45964b8b1557e8f2f13fb5f3adab5faa8be1-007", + "gas": "443359442322" + } + } + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "hash-624dbe2395b9d9503fbee82162f1714ebff6b639f96d2084d26d944c354ec4c5", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": "Identity" + }, + { + "key": "hash-8cf5e4acf51f54eb59291599187838dc3bc234089c46fc6ca8ad17e762ae4401", + "transform": "Identity" + }, + { + "key": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655", + "transform": "Identity" + }, + { + "key": "hash-010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7", + "transform": "Identity" + }, + { + "key": "hash-9824d60dc3a5c44a20b9fd260a412437933835b52fc683d8ae36e4ec2114843e", + "transform": "Identity" + }, + { + "key": "hash-010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7", + "transform": "Identity" + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": "Identity" + }, + { + "key": "balance-11e6fc5354f61a004df98482376c45964b8b1557e8f2f13fb5f3adab5faa8be1", + "transform": "Identity" + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": { + "WriteCLValue": { + "cl_type": "U512", + "bytes": "055bdf0a5c67", + "parsed": "443925847899" + } + } + }, + { + "key": "balance-11e6fc5354f61a004df98482376c45964b8b1557e8f2f13fb5f3adab5faa8be1", + "transform": { + "AddUInt512": "56074152101" + } + }, + { + "key": "hash-010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7", + "transform": "Identity" + }, + { + "key": "hash-9824d60dc3a5c44a20b9fd260a412437933835b52fc683d8ae36e4ec2114843e", + "transform": "Identity" + }, + { + "key": "hash-010c3fe81b7b862e50c77ef9a958a05bfa98444f26f96f23d37a13c96244cfb7", + "transform": "Identity" + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": "Identity" + }, + { + "key": "balance-dcf5abbbe00715e9a05f7449109b1d297cb1584560ec4f3f5a86401452e40d85", + "transform": "Identity" + }, + { + "key": "balance-98d945f5324f865243b7c02c0417ab6eac361c5c56602fd42ced834a1ba201b6", + "transform": { + "WriteCLValue": { + "cl_type": "U512", + "bytes": "00", + "parsed": "0" + } + } + }, + { + "key": "balance-dcf5abbbe00715e9a05f7449109b1d297cb1584560ec4f3f5a86401452e40d85", + "transform": { + "AddUInt512": "443925847899" + } + } + ] + }, + "transfers": [], + "cost": "443359442322" + } + } + } + ] + } +} +``` + +
## Next Steps - Learn to [Query](./querying-NFTs.md) the NFT contract - Learn to [Mint, Transfer, and Burn](./interacting-with-NFTs.md) NFT tokens - diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index f670761e..2a0a8aad 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -2,11 +2,13 @@ This document describes how to transfer NFTs on a Casper network using the Casper client. + ## Prerequisites - Install the contract using the [Quickstart](./quickstart-guide.md) or the [Full Installation](./full-installation-tutorial.md) tutorials - Learn to [Query NFT Contracts](./querying-NFTs.md) and save the various hashes and URefs required throughout this document + ## Table of Contents 1. [Directly Invoking Entrypoints](#directly-invoking-entrypoints) @@ -29,42 +31,80 @@ You may invoke the `mint`, `transfer`, or `burn` entrypoints directly through ei In the case of `mint`, fewer runtime arguments must be provided, thereby reducing the total gas cost of minting an NFT.
-Example Mint using StoredVersionByHash +Example `mint` using the stored package hash ```bash - -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ ---session-package-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ +casper-client put-deploy --node-address http://localhost:11101/rpc/ \ +--chain-name "casper-net-1” \ +--payment-amount 5000000000 \ +--secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--session-package-hash hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30 \ --session-entry-point "mint" \ ---session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ +--session-arg "token_owner:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'" \ --session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" - ```
-Example Transfer using StoredContractByHash +Example `transfer` using the stored contract hash Based on the identifier mode for the given contract instance, either the `token_id` runtime argument must be passed in or, in the case of the hash identifier mode, the `token_hash` runtime argument. ```bash - -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 7500000000 \ -k ~/secret_key.pem \ ---session-hash hash-b3b7a74ae9ef2ea8afc06d6a0830961259605e417e95a53c0cb1ca9737bb0ec7 \ +casper-client put-deploy --node-address http://localhost:11101/rpc/ \ +--chain-name "casper-net-1” \ +--payment-amount 5000000000 \ +--secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--session-hash hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796 \ --session-entry-point "transfer" \ ---session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ ---session-arg "target_key:key='account-hash-b4782e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ +--session-arg "source_key:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'" \ +--session-arg "target_key:key='account-hash-0ea7998b2822afe5b62b08a21d54c941ad791279b089f3f7ede0d72b477eca34'" \ --session-arg "token_id:u64='0'" - ```
-## Minting NFTs using Wasm + +## Minting NFTs Below is an example of a `casper-client` command that uses the `mint` entrypoint of the contract to mint an NFT for the user associated with `node-1` in an [NCTL environment](https://docs.casper.network/developers/dapps/nctl-test/). +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-entry-point "mint"` + +1. `--session-package-hash hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30` + + The package hash of the previously installed CEP-78 NFT contract from which we will be minting. + +2. `--session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` + + The collection name of the NFT to be minted. + +3. `--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'"` + + Metadata describing the NFT to be minted, passed in as a `string`. + +
+Casper client command without comments + +```bash +casper-client put-deploy --node-address http://localhost:11101/rpc/ \ +--chain-name "casper-net-1” \ +--payment-amount 5000000000 \ +--secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--session-entry-point "mint" \ +--session-package-hash hash-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30 \ +--session-arg "token_owner:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'" \ +--session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" +``` + +
+ + +### Minting NFTs using Wasm + +This example invokes the `mint_call.wasm` session code provided in the `client` folder. + - `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm` 1. `--session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'"` @@ -88,25 +128,27 @@ Below is an example of a `casper-client` command that uses the `mint` entrypoint Casper client command without comments ```bash -casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ +casper-client put-deploy --node-address http://localhost:11101/rpc/ \ +--chain-name "casper-net-1” \ --payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--secret-key ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ --session-path ~/casper/enhanced-nft/client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm \ --session-arg "nft_contract_hash:key='hash-206339c3deb8e6146974125bb271eb510795be6f250c21b1bd4b698956669f95'" \ ---session-arg "collection_name:string='cep78_'"` \ +--session-arg "collection_name:string='cep78_'" \ --session-arg "token_owner:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ --session-arg "token_meta_data:string='{\"name\": \"John Doe\",\"token_uri\": \"https:\/\/www.barfoo.com\",\"checksum\": \"940bffb3f2bba35f84313aa26da09ece3ad47045c6a1292c2bbd2df4ab1a55fb\"}'" ``` + ## Transferring NFTs -Below is an example of a `casper-client` command that uses the `transfer` entrypoint to transfer ownership of an NFT from one user to another. In this case, the command transfers a previously minted NFT from the user associated with `node-2` to the user associated with `node-3`. +Below is an example of a `casper-client` command that uses the `transfer` entrypoint to transfer ownership of an NFT from one user to another. -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-entry-point "transfer"` +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-entry-point "transfer"` -1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` +1. `--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` The contract hash of the CEP-78 NFT Contract associated with the NFT to be transferred. @@ -132,9 +174,9 @@ Below is an example of a `casper-client` command that uses the `transfer` entryp ```bash casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ --session-entry-point "transfer" \ ---session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'" \ +--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5 \ --session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ --session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ --session-arg "is_hash_identifier_mode:bool='false'" \ @@ -145,9 +187,10 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net- This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance as shown [below](#invoking-the-balance_of-entry-point). + ### Transferring NFTs using Wasm -Below is an example of a `casper-client` command that uses the `transfer` Wasm to transfer ownership of an NFT from one user to another. +This example uses the `transfer_call.wasm` session code to transfer ownership of an NFT from one user to another. - `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/secret_key.pem --session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm` @@ -178,7 +221,7 @@ Below is an example of a `casper-client` command that uses the `transfer` Wasm t casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" \ --payment-amount 5000000000 \ -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ ---session-entry-point "transfer" \ +--session-path ~/casper/enhanced-nft/client/transfer_session/target/wasm32-unknown-unknown/release/transfer_call.wasm \ --session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'" \ --session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'" \ --session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'" \ @@ -188,58 +231,24 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net- -### Invoking the `balance_of` Entry Point -The following Casper client command invokes the `balance_of` entry point on the `cep78_test_contract`. +## Checking the Balance -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ ---secret-key [PATH_TO_SECRET_KEY] \ ---session-package-name "cep78_test_contract" \ ---session-entry-point "balance_of" \ -// The contract hash of your CEP-78 contract instance, passed in as an `account-hash-`. ---session-arg "token_contract:account_hash='account-hash-[HASH]'" \ -// The account hash of the account whose balance you are checking. ---session-arg "address:key='account-hash-[HASH]'" \ ---payment-amount 1000000000 -``` +The following command invokes the `balance_of` entry point and saves the amount of tokens owned under the account's named keys. -
-Casper client command without comments +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm` -```bash -casper-client put-deploy -n http://localhost:11101/rpc/ \ ---chain-name "casper-net-1" \ ---payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ ---session-package-name "cep78_test_contract" \ ---session-entry-point "balance_of" \ ---session-arg "token_contract:account_hash='account-hash-b568f50a64acc8bbe43462ffe243849a88111060b228dacb8f08d42e26985180'" \ ---session-arg "address:key='account-hash-303c0f8208220fe9a4de40e1ada1d35fdd6c678877908f01fddb2a56502d67fd'" \ -``` +1. `--session-arg "nft_contract_hash:key='hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796'"` -
+ The contract hash of the previously installed CEP-78 NFT contract. -## Approving Another Account +2. `--session-arg "token_owner:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'"` -The Casper NFT contract features an `approve` entry point that allows an account to delegate another account to spend a preset number of CEP-78 tokens from their balance. + The account hash of the user whose token balance we are checking. -The following command approves another account to spend 15 tokens from the balance of the account that installed and owns the CEP-78 contract instance. +3. `--session-arg "key_name:string='balance'"` -```bash -casper-client put-deploy -n http:// \ ---chain-name [CHAIN_NAME] \ ---secret-key [PATH_TO_SECRET_KEY] \ -// The contract hash of the CEP-78 token contract. ---session-hash [CEP-78_CONTRACT_HASH] \ ---session-entry-point "approve" \ -// The account hash of the account that will receive an allowance from the balance of the account that sent the Deploy. ---session-arg "spender:key='account-hash-[HASH]'" \ -// The number of CEP-78 tokens included in the allowance. ---session-arg "amount:u256='15'" \ ---payment-amount "10000000000" -``` + The name for the entry under the `NamedKeys` under which the balance amount will be stored
Casper client command without comments @@ -248,40 +257,33 @@ casper-client put-deploy -n http:// \ casper-client put-deploy -n http://localhost:11101/rpc/ \ --chain-name "casper-net-1" \ --payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ ---session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ ---session-entry-point "approve" \ ---session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ ---session-arg "amount:u256='15'" +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--session-path ~/casper/enhanced-nft/client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm \ +--session-arg "nft_contract_hash:key='hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796'" \ +--session-arg "token_owner:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'" \ +--session-arg "key_name:string='balance'" ```
-### Transferring Tokens from an Approved Account - -The following command allows an account to transfer CEP-78 tokens held by another account up to their approved allowance. The command is similar to the transfer example above. - -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem --session-entry-point "transfer"` - -1. `--session-arg "nft_contract_hash:key='hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5'"` - The contract hash of the CEP-78 NFT Contract associated with the NFT to be transferred. +## Approving an Account -2. `--session-arg "source_key:key='account-hash-e9ff87766a1d2bab2565bfd5799054946200b51b20c3ca7e54a9269e00fe7cfb'"` +The Casper NFT contract features an `approve` entry point allowing another account to manage a specific token. During contract installation, the `ownership_mode` must be set to 2, meaning `Transferable`. - The account hash of the user that currently owns the NFT and wishes to transfer it. +- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-entry-point "approve"` -3. `--session-arg "target_key:key='account-hash-b4772e7c47e4deca5bd90b7adb2d6e884f2d331825d5419d6cbfb59e17642aab'"` +1. `--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5` - The account hash of the user that will receive the NFT. + The contract hash of the previously installed CEP-78 NFT contract. -4. `--session-arg "is_hash_identifier_mode:bool='false'"` +2. `--session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'"` - Argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. + The hash of the account receiving the approval. -5. `--session-arg "token_id:u64='0'"` +3. `--session-arg "token_id:u64='1'"` - The `token_id` of the NFT to be transferred. + The token ID of the approved NFT.
@@ -291,14 +293,13 @@ The following command allows an account to transfer CEP-78 tokens held by anothe casper-client put-deploy -n http://localhost:11101/rpc/ \ --chain-name "casper-net-1" \ --payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-2/keys/secret_key.pem \ ---session-hash hash-05d893e76c731729fc26339e5a970bd79fbf4a6adf743c8385431fb494bff45e \ ---session-entry-point "transfer" \ ---session-arg "owner:key='account-hash-39f15c23df9be1244572bb499fac62cbcad3cab2dc1438609842f602f943d7d2'" \ ---session-arg "recipient:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ ---session-arg "amount:u256='10'" \ ---payment-amount "10000000000" +-k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ +--session-entry-point "approve" \ +--session-hash hash-52e78ae3f6c485d036a74f65ebbb8c75fcc7c33fb42eb667fb32aeba72c63fb5 \ +--session-arg "spender:key='account-hash-17192017d32db5dc9f598bf8ac6ac35ee4b64748669b00572d88335941479513'" \ +--session-arg "token_id:u64='1'" ``` +
@@ -334,6 +335,7 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net- -### Next Steps + +## Next Steps - [Testing Framework for CEP-78](./testing-NFTs.md) \ No newline at end of file diff --git a/docs/tutorials/getting-started/querying-NFTs.md b/docs/tutorials/getting-started/querying-NFTs.md index 5c72b7e7..18bf5a4d 100644 --- a/docs/tutorials/getting-started/querying-NFTs.md +++ b/docs/tutorials/getting-started/querying-NFTs.md @@ -18,152 +18,193 @@ First, identify the contract hash by looking at the account that installed the c Next, query the contract details. -```bash -casper-client query-global-state -n http:// \ -// This is the contract hash, found within the `NamedKeys` of the account that sent the installing deploy. ---key hash-30767a108fedcb8872a0cec5eabb76f743f1bf3bbac9cac6e9c15355ae17d61a \ -// This is the most up-to-date state root hash, which can be found by using the `get-state-root-hash` command in the Casper client. ---state-root-hash ca9ad2c99188cdbb8ceeccff16c6225b53b8c2e01dff945fb7ff3e33b427faf5 -``` +- `casper-client query-global-state -n http://localhost:11101/rpc/` -
-Casper client command without comments +1. `--key [CONTRACT_HASH]` -```bash -casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ ---key hash-30767a108fedcb8872a0cec5eabb76f743f1bf3bbac9cac6e9c15355ae17d61a \ ---state-root-hash ca9ad2c99188cdbb8ceeccff16c6225b53b8c2e01dff945fb7ff3e33b427faf5 -``` + The contract hash, found within the `NamedKeys` of the account that sent the installing deploy. -
-
+2. `--state-root-hash [STATE_ROOT_HASH]` + + The most up-to-date state root hash, which can be found by using the `get-state-root-hash` command in the Casper client.
-Expand to see the contract +Expand to see the query and sample contract + + +```bash +casper-client query-global-state -n http://localhost:11101/rpc/ \ +--key hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796 \ +--state-root-hash 2a8cfc20d24b4bc629ea6d26cc820560a1baf3d4275079d5382242c9fa1e86fe +``` ```json { "jsonrpc": "2.0", - "id": -5249732042108614691, + "id": -5355991397545050403, "result": { "api_version": "1.5.6", "block_header": null, "stored_value": { "Contract": { - "contract_package_hash": "contract-package-c6bb687a72d0aa341317ef85cc8668c6627f0c1e8233ead4aa97e0399c9366ea", - "contract_wasm_hash": "contract-wasm-f8fadaf90a26db147a56005891b2fc7f33c90ea4d39f533078be36894d99cff1", + "contract_package_hash": "contract-package-2b61207cd0e94ce1b1d40801b0abb1ab55fd7dae94c9dcf670292243f3791a30", + "contract_wasm_hash": "contract-wasm-845d3d08e29642afba35704bcb6e38f3c40f1469763bff7a88674c9a5be3f01b", "named_keys": [ + { + "name": "acl_package_mode", + "key": "uref-5e950cdd5497633c1d03284ec6e70ce436744cc172d6e26e21e4e474d1b34312-007" + }, + { + "name": "acl_whitelist", + "key": "uref-77b5861bdc04f3c63417dd2ed1943f659f6180603982a24587f79cbc38801cf4-007" + }, { "name": "allow_minting", - "key": "uref-f4aa245fb70fdc6557cbbc61703629f616a2d5c270ee0c427147947d8cd8b12c-007" + "key": "uref-dca79aa4244d0123ad52799fc4f922b2ae9fc023c9e56f999979f535a792eef5-007" + }, + { + "name": "approved", + "key": "uref-76aac8f7224c5c1624b4255fff59ecc8ee2c7a1ba460b4f70945d7548abbffd0-007" }, { "name": "balances", - "key": "uref-953333e2c0249bd7db687b43cb2585d0ad5356eb7be6c4f56479070d3c33c1dd-007" + "key": "uref-3d271bac2030ddee54bf4ea92b9b854d800a10a0df5d6e328a045be19af27538-007" }, { "name": "burn_mode", - "key": "uref-9791a13ce6c3d3251607073c75fb548dcf70a6a84f2847845b08b7e797a9b40b-007" + "key": "uref-eb1a7f69592881587805fde2d53e8e5b3dcbabd81311faa7b9d19ea731f83d9b-007" }, { "name": "burnt_tokens", - "key": "uref-704d3105e3ee90e3f072f04333dd1644a3617013588981b18fa01afe570b6a97-007" + "key": "uref-0c144d231ac070adb2668f2a9f3d0eba32c7468efa879f0f29c832c63698966b-007" + }, + { + "name": "cep78_CEP-78-collection2", + "key": "uref-ac99c07d666f45ff5c86a2c1bb6cc44b612ddd5d39a9de88045b441ff6e6b327-007" }, { "name": "collection_name", - "key": "uref-2957503e067a14bb8017b17af807699998b17cb2889a351dce8aeb8d6c4672fd-007" + "key": "uref-5aed76a73089e7e32f6fbf5d9a9597843215d4810cd5822c0f5c6e65a0bbb7a3-007" }, { "name": "collection_symbol", - "key": "uref-be0d965414348f285c698dc67371a7dbc8974d4cd957f1cf162f0d6ce2fe215b-007" + "key": "uref-ba4247cc0354644474758d1292924c5115c61c8012cae3f094a91060d9dff779-007" }, { - "name": "contract_whitelist", - "key": "uref-b2dd80cc9ea15fee10c841e49eb2db724ca4af85b47be5d37793994d879e97ec-007" + "name": "events_mode", + "key": "uref-51acad53fd1a6ce6a52cf83ed7f921565311ed86cd362969bacf9457b6bf5c1a-007" + }, + { + "name": "hash_by_index", + "key": "uref-e280dd23c847724422543b0d70f1ed4c95c8da9e1a71927ae39add652859775c-007" }, { "name": "holder_mode", - "key": "uref-a561a0171e7bfffcfe7c8e487c0f4e3528a807152c27d5b235445a3aad21a016-007" + "key": "uref-8443151d736bb3268815ad7848708d44ccc661799f969697c64b1cddb5ce89a7-007" }, { "name": "identifier_mode", - "key": "uref-5f7b8694da08e7b7c9f7613cd02da4c19aa0f3b26db033c09e4d42920a5f284d-007" + "key": "uref-f53ea99b60ae6d046a6fb0d996475714ef03ed33b39674a8fe016c8324116baf-007" + }, + { + "name": "index_by_hash", + "key": "uref-6299c9322631f374fc1a5e20920641b23f437a3c0ba8da22cc23cba11b0fa3a5-007" }, { "name": "installer", - "key": "account-hash-5cb74580bcf97d0a7fa034e60b3d2952e0b170ea5162153b1570e8b1ee4ec3f5" + "key": "account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655" }, { "name": "json_schema", - "key": "uref-fcc796a2d21efbbf777d1e5f1e6436ab4b0ba9a308c63502b0a26f82b4e53f21-007" + "key": "uref-772103052d4559fcc2f8f2c2568eb75214462d463009106938e6f20e1cc0a7c0-007" }, { "name": "metadata_cep78", - "key": "uref-64e0268f09395f215ee71dd668ac3e6f8fbf6b9340ee88d0e5381996ae577c0e-007" + "key": "uref-2c2176a9efd465d2e4d5de05d75d029e03040d0a5668c4e08facb0cd3442d30a-007" }, { "name": "metadata_custom_validated", - "key": "uref-000c5609c2f884d4ae1bb3406f3ba1a9ce5fbe03eaa8dd6edd6d42ea7d4e43e9-007" + "key": "uref-575108b0258e92ebede1e50345b608d42963bdac24379022be20b76cfde15301-007" }, { "name": "metadata_mutability", - "key": "uref-eabf6aa4701272e56012b3567403434368aac7f6d43b5c26cc3ab5b29e96d14b-007" + "key": "uref-2ca963a70a69df2db931b8761b4de13bd22e2fc54a415b0b57d4204c9b90dde9-007" }, { "name": "metadata_nft721", - "key": "uref-585836baca4e24d53234671c7e70ab1f5d2d8ed9e6eb083218365d71700f7626-007" + "key": "uref-eb37c0fe3b53fa5c72b02976f2840b7bf3692954fc830f8a10dc538d0c506e63-007" }, { "name": "metadata_raw", - "key": "uref-5d7a570165127633392eb40e8b899fa7d5f0fc90f589e6d425994aac050a7cae-007" + "key": "uref-cdb17062423b769a7b0bc18fe0a2202b68d2ba77786291018a24fd53f4532ab8-007" }, { "name": "minting_mode", - "key": "uref-81a08d4b64c0a8c08ef75b164da3ae3914883224857632ab4f476f386e853d01-007" + "key": "uref-3b45a30c98d90de2c62812c6689aa2fac0cb4d08772fcfdee0584c5db2b1d12a-007" }, { "name": "nft_kind", - "key": "uref-a50039ae7e9191fed14bff1b1404538189894d2bf7d279672c1b0ec4e7f6441b-007" + "key": "uref-e02c29a6120d5da7f14fb664ca60c3ade56a3171a670c292d0a4ea0f9ae4f0c8-007" }, { "name": "nft_metadata_kind", - "key": "uref-0c8b9018f09e90d2823134cdf0d70cdec08decaaa822aa1311e79242b616e4d3-007" + "key": "uref-45e1bc671353ae58c41a703055959da243deefc7f4c3f121f3f9828d97475bda-007" + }, + { + "name": "nft_metadata_kinds", + "key": "uref-05c0eb8e7ef4caa6f228e8ee91874dc64926b95926d839b458fdce356063a817-007" }, { "name": "number_of_minted_tokens", - "key": "uref-c02c67cc721aa82ecd70adae2647b94125dde3fb4899a44ab03c944f3dfe7923-007" + "key": "uref-f86e2c4057cc17d93593fb203a923d67e5bc68e6428a6d94f6eab0c35450653d-007" }, { - "name": "operator", - "key": "uref-6ced629a6c54e24ca0a2c4af0cce2a69139fac7461294234bd91b442886e0c13-007" + "name": "operator_burn_mode", + "key": "uref-f226eed9d0c5fcf58e6b481d45417721e35435c2ef5eb4d26d215209149438ba-007" }, { - "name": "owned_tokens", - "key": "uref-456e98216d72a0a1a0427fb6ddf4cc7070d1450faa841cf381c821c415092228-007" + "name": "operators", + "key": "uref-ff8ad952307b57a051ef6cb597a55cc2007e587c575584addf6a6fc12c0efd7b-007" }, { "name": "ownership_mode", - "key": "uref-b23f6166e076cc347ab0ba68343e51d3ecf9808e6a960386f5fc8af8cdce4df8-007" + "key": "uref-89711af74265427dc65d7c5a421cedde82de69d192cad36f34efa36504108572-007" + }, + { + "name": "package_operator_mode", + "key": "uref-05c2868f179f6b2323f1d4ea069858956c9666d14073748aae4a748d27a8a894-007" + }, + { + "name": "page_table", + "key": "uref-00efcfa874a60b5b615b3c6d781cf69c3559b5372d15457fe4a3bb6d07c66acd-007" }, { "name": "receipt_name", - "key": "uref-006512abe036cf2b923418a22c426fd59d88a812a8e3c478c630faa376e20832-007" + "key": "uref-1ec63ea6442d9b4ef40d926280f8b72704b763d3ef7cdaccd9ecb04af5562d99-007" + }, + { + "name": "reporting_mode", + "key": "uref-4d851152d7b89dff805dcf6eb61a33870dab9345084a5874575476a584d71b83-007" + }, + { + "name": "rlo_mflag", + "key": "uref-2e3b8aafb27aae47c9b7d3728d20d8815b706e2245c23b84f0e712cd1d1e9124-007" }, { "name": "token_issuers", - "key": "uref-5ba273a67b785a6580d0784362f09761c4bb9f0e261c8a583e74af0ab68fe010-007" + "key": "uref-5700d04b36eb1f50204c0d1d05c8ed6aae77eaeaa8a425c78f5a24cbae2e4d26-007" }, { "name": "token_owners", - "key": "uref-962891f947726ef87e6988d26ae5bb65c1376520278a149ea0044aafc94f3a91-007" + "key": "uref-ff53b7094bcb6659b558d31fdf63f837b05c0ee6030bfe18ad4c3fb0462b9b17-007" }, { "name": "total_token_supply", - "key": "uref-e2116be250c30901324f4590683774a83577a51b174274d371c38d574b065d90-007" + "key": "uref-e5f06deadcbfe5a469e7c162346580744746bfdc0ec67002e0ecba5b11096827-007" }, { "name": "whitelist_mode", - "key": "uref-ab9b9c51e591e56e8042a1ae6649dad31d52be6febc4aba62c414ff069089bf6-007" + "key": "uref-a77f2ac1f5e72c6b096ca414ae2c986a5387442ddf8e89a35b787a756adc4bb4-007" } ], "entry_points": [ @@ -171,7 +212,7 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ "name": "approve", "args": [ { - "name": "operator", + "name": "spender", "cl_type": "Key" } ], @@ -247,13 +288,19 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ "cl_type": "U8" }, { - "name": "contract_whitelist", + "name": "acl_whitelist", "cl_type": { - "List": { - "ByteArray": 32 - } + "List": "Key" } }, + { + "name": "acl_package_mode", + "cl_type": "Bool" + }, + { + "name": "package_operator_mode", + "cl_type": "Bool" + }, { "name": "json_schema", "cl_type": "String" @@ -269,12 +316,54 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ { "name": "burn_mode", "cl_type": "U8" + }, + { + "name": "operator_burn_mode", + "cl_type": "Bool" + }, + { + "name": "nft_metadata_kind", + "cl_type": "U8" + }, + { + "name": "metadata_mutability", + "cl_type": "U8" + }, + { + "name": "owner_reverse_lookup_mode", + "cl_type": "U8" + }, + { + "name": "events_mode", + "cl_type": "U8" + }, + { + "name": "transfer_filter_contract", + "cl_type": { + "Option": "Key" + } } ], "ret": "Unit", "access": "Public", "entry_point_type": "Contract" }, + { + "name": "is_approved_for_all", + "args": [ + { + "name": "token_owner", + "cl_type": "Key" + }, + { + "name": "operator", + "cl_type": "Key" + } + ], + "ret": "Bool", + "access": "Public", + "entry_point_type": "Contract" + }, { "name": "metadata", "args": [], @@ -282,6 +371,18 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ "access": "Public", "entry_point_type": "Contract" }, + { + "name": "migrate", + "args": [ + { + "name": "cep78_package_key", + "cl_type": "Any" + } + ], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, { "name": "mint", "args": [ @@ -311,13 +412,28 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ "access": "Public", "entry_point_type": "Contract" }, + { + "name": "register_owner", + "args": [], + "ret": { + "Tuple2": [ + "String", + "URef" + ] + }, + "access": "Public", + "entry_point_type": "Contract" + }, + { + "name": "revoke", + "args": [], + "ret": "Unit", + "access": "Public", + "entry_point_type": "Contract" + }, { "name": "set_approval_for_all", "args": [ - { - "name": "token_owner", - "cl_type": "Key" - }, { "name": "approve_all", "cl_type": "Bool" @@ -357,6 +473,24 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ "ByteArray": 32 } } + }, + { + "name": "acl_whitelist", + "cl_type": { + "List": "Key" + } + }, + { + "name": "acl_package_mode", + "cl_type": "Bool" + }, + { + "name": "package_operator_mode", + "cl_type": "Bool" + }, + { + "name": "operator_burn_mode", + "cl_type": "Bool" } ], "ret": "Unit", @@ -383,12 +517,26 @@ casper-client query-global-state -n hhttp://localhost:11101/rpc/ \ }, "access": "Public", "entry_point_type": "Contract" + }, + { + "name": "updated_receipts", + "args": [], + "ret": { + "List": { + "Tuple2": [ + "String", + "Key" + ] + } + }, + "access": "Public", + "entry_point_type": "Contract" } ], - "protocol_version": "1.4.10" + "protocol_version": "1.5.6" } }, - "merkle_proof": "[31286 hex chars]" + "merkle_proof": "[33244 hex chars]" } } ``` From 874edb4bb18ffe33efd29cbdde78d3797761b406 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 1 Mar 2024 20:32:34 +0100 Subject: [PATCH 15/26] Minor edits --- .../getting-started/full-installation-tutorial.md | 10 +++++----- .../getting-started/interacting-with-NFTs.md | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/tutorials/getting-started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md index 5309657a..8ca14ac7 100644 --- a/docs/tutorials/getting-started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -1,6 +1,6 @@ # Installing an NFT Contract using the Rust Casper Client -This documentation will guide you through the process of installing and interacting with an instance of the CEP-78 enhanced NFT standard contract through Casper's Rust CLI client. The contract code installs an instance of CEP-78 as per session arguments provided at the time of installation. It requires a minimum Rust version of `1.63.0`. The code for this tutorial is available in [GitHub](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). A portion of this tutorial reviews the [contract](../../../contract/src/main.rs). +This documentation will guide you through installing and interacting with an instance of the CEP-78 enhanced NFT standard contract through Casper's Rust CLI client. The contract code installs an instance of CEP-78 given the session arguments provided. It requires a minimum Rust version of `1.63.0`. The code for this tutorial is available in [GitHub](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). A portion of this tutorial reviews the [contract](../../../contract/src/main.rs). Information on the modalities used throughout this installation process can be found in the [modalities documentation](modalities.md). @@ -34,7 +34,7 @@ The [Writing Rust Contracts on Casper](https://docs.casper.network/developers/wr ### Building the Contract and Tests -First clone the contract from GitHub: +First, clone the contract from GitHub: ```bash git clone https://github.com/casper-ecosystem/cep-78-enhanced-nft/ && cd cep-78-enhanced-nft @@ -143,7 +143,7 @@ There is also the [**migrate**](https://github.com/casper-ecosystem/cep-78-enhan ## Installing the Contract -Installing the enhanced NFT contract to global state requires the use of a [Deploy](https://docs.casper.network/developers/dapps/sending-deploys/). But before proceeding with the installation, verify the network state and the status of the account that will send the installation deploy. +Installing the enhanced NFT contract to global state requires using a [Deploy](https://docs.casper.network/developers/dapps/sending-deploys/). But before proceeding with the installation, verify the network state and the status of the account that will send the installation deploy. ### Querying Global State @@ -232,7 +232,7 @@ Use the Testnet to understand the exact gas amount required for installation. Re 4. `--session-arg "ownership_mode:u8='2'"` - The ownership mode for this contract. In this instance the 2 represents "Transferable" mode. Under these conditions, users can freely transfer their NFTs between one another. + The ownership mode for this contract. In this instance, the 2 represents "Transferable" mode. Under these conditions, users can freely transfer their NFTs between one another. 5. `--session-arg "nft_kind:u8='1'"` @@ -244,7 +244,7 @@ Use the Testnet to understand the exact gas amount required for installation. Re 7. `--session-arg "json_schema:string=''"` - An empty JSON string, as the contract has awareness of the CEP-78 JSON schema. Using the custom validated modality would require passing through a valid JSON schema for your custom metadata. + An empty JSON string, as the contract has awareness of the CEP-78 JSON schema. Using the custom-validated modality would require passing through a valid JSON schema for your custom metadata. 8. `--session-arg "identifier_mode:u8='0'"` diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index 2a0a8aad..01e65159 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -1,6 +1,6 @@ # Interacting with the NFT Contract using the Rust Casper Client -This document describes how to transfer NFTs on a Casper network using the Casper client. +This document describes interacting with NFTs on a Casper network using the Rust command-line client. ## Prerequisites @@ -24,7 +24,7 @@ This document describes how to transfer NFTs on a Casper network using the Caspe ## Directly Invoking Entrypoints -With the release of CEP-78 version 1.1, users who are interacting with a CEP-78 contract that does not use `ReverseLookupMode` should opt out of using the client Wasm files provided as part of the release. Opting out in this situation is recommended, as directly invoking the entrypoints incurs a lower gas cost compared to using the provided client Wasm to invoke the entrypoint. +With the release of CEP-78 version 1.1, users interacting with a CEP-78 contract that does not use `ReverseLookupMode` should opt out of using the client Wasm files provided as part of the release. Opting out in this situation is recommended, as directly invoking the entrypoints incurs a lower gas cost than using the provided client Wasm to invoke the entrypoint. You may invoke the `mint`, `transfer`, or `burn` entrypoints directly through either the contract package hash or the contract hash directly. @@ -162,7 +162,7 @@ Below is an example of a `casper-client` command that uses the `transfer` entryp 4. `--session-arg "is_hash_identifier_mode:bool='false'"` - Argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. + The argument that the hash identifier mode is ordinal, thereby requiring a `token_id` rather than a `token_hash`. 5. `--session-arg "token_id:u64='0'"` @@ -185,7 +185,7 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-
-This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entry point to verify the account's balance as shown [below](#invoking-the-balance_of-entry-point). +This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entrypoint to verify the account's balance as shown [below](#invoking-the-balance_of-entry-point). ### Transferring NFTs using Wasm @@ -234,7 +234,7 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net- ## Checking the Balance -The following command invokes the `balance_of` entry point and saves the amount of tokens owned under the account's named keys. +The following command invokes the `balance_of_call.wasm` and saves the number of tokens owned under the account's named keys. - `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm` @@ -248,7 +248,7 @@ The following command invokes the `balance_of` entry point and saves the amount 3. `--session-arg "key_name:string='balance'"` - The name for the entry under the `NamedKeys` under which the balance amount will be stored + The name for the entry under the `NamedKeys` under which the balance amount will be stored.
Casper client command without comments @@ -269,7 +269,7 @@ casper-client put-deploy -n http://localhost:11101/rpc/ \ ## Approving an Account -The Casper NFT contract features an `approve` entry point allowing another account to manage a specific token. During contract installation, the `ownership_mode` must be set to 2, meaning `Transferable`. +The Casper NFT contract features an `approve` entrypoint, allowing another account to manage a specific token. During contract installation, the `ownership_mode` must be set to 2, meaning `Transferable`. - `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-entry-point "approve"` From f053c8ed6980c5ac45a029053d2b4d22e84b51e2 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 1 Mar 2024 22:40:08 +0100 Subject: [PATCH 16/26] Fix old links --- CHANGELOG.md | 10 +++++----- client-js/TUTORIAL.md | 4 ++-- docs/modalities.md | 4 ++-- docs/tutorials/custom-migration-tutorial.md | 12 ++++++------ docs/tutorials/standard-migration-tutorial.md | 12 ++++++------ docs/tutorials/token-ownership-tutorial.md | 12 ++++++------ 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20ddc6b3..c7bcc906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,7 @@ All notable changes to this project will be documented in this file. The format - Transfer Filter Hook. The transfer filter modality, if enabled, specifies a contract package hash pointing to a contract that will be called when the `transfer` method is invoked on the contract. -- Added the `ACL` option to the `minting_mode` modality. This option allows only whitelisted accounts or contracts to mint tokens. More information can be found [here](./README.md/#minting). +- Added the `ACL` option to the `minting_mode` modality. This option allows only whitelisted accounts or contracts to mint tokens. More information can be found [here](./docs/modalities.md#minting). ## Release 1.3.0 @@ -77,9 +77,9 @@ All notable changes to this project will be documented in this file. The format ### Added -- Added a new modality named `EventsMode` that dictates how the installed instance of CEP-78 will handle the recording of events. Refer to the [README](./README.md#eventsmode) for further details +- Added a new modality named `EventsMode` that dictates how the installed instance of CEP-78 will handle the recording of events. Refer to the [README](./docs/modalities.md#eventsmode) for further details -- Added the ability for the contract to specify one or more metadata schemas, with the option to further specify optional metadata schemas. Additional required metadatas are specified by `additional_required_metadata`, while additional optional metadata schemas can be specified using `optional_metadata`. Refer to the [`Installing the Contract`](./README.md#installing-the-contract) section of the README for more information on using these arguments. +- Added the ability for the contract to specify one or more metadata schemas, with the option to further specify optional metadata schemas. Additional required metadatas are specified by `additional_required_metadata`, while additional optional metadata schemas can be specified using `optional_metadata`. Refer to the [`Installing the Contract`](./docs/tutorials/getting-started/full-installation-tutorial.md) section of the README for more information on using these arguments. - When upgrading from a contract instance, you may now change the `total_token_supply` to a number higher than the current number of minted tokens, but lower than your previous total. The number cannot be zero. More information is available in the upgrade tutorials. @@ -91,7 +91,7 @@ All notable changes to this project will be documented in this file. The format ### Changed -- `OwnerReverseLookupMode` now contains an additional option, `TransfersOnly`, which begins tracking ownership upon transfer. More information can be found [here](./README.md#ownerreverselookupmode). +- `OwnerReverseLookupMode` now contains an additional option, `TransfersOnly`, which begins tracking ownership upon transfer. More information can be found [here](./docs/modalities.md#ownerreverselookupmode). - Optimized the `set_approval_for_all` entrypoint implementation to reduce gas costs. @@ -113,7 +113,7 @@ All notable changes to this project will be documented in this file. The format - To allow isolation of the additional costs, or tracking individual owners, the reverse lookup mode supports a register entrypoint which is used to register owners prior to minting or receiving a transferred token. In either `Assigned` or `Transferable` mode, this register entrypoint can be called by any party on behalf of another party. - - As a result of this change, the previously used `owned_tokens` dictionary is now deprecated. Moving forward, token ownership will be tracked using the `OwnerReverseLookupMode` modality and [CEP-78 Page System](./README.md#the-cep-78-page-system). + - As a result of this change, the previously used `owned_tokens` dictionary is now deprecated. Moving forward, token ownership will be tracked using the `OwnerReverseLookupMode` modality and [CEP-78 Page System](./docs/reverse-lookup.md#the-cep-78-page-system). ### Changed diff --git a/client-js/TUTORIAL.md b/client-js/TUTORIAL.md index 455f6247..2ba2437c 100644 --- a/client-js/TUTORIAL.md +++ b/client-js/TUTORIAL.md @@ -67,7 +67,7 @@ As with every deploy created by the SDK, you can send it using the `.send(rpcUrl * `nftKind` - The `NFTKind` modality that specifies the off-chain items represented by the on-chain NFT data. This argument is passed in as a `u8` value and is required at the time of installation. -* `jsonSchema` - The JSON schema for the NFT tokens that will be minted by the NFT contract passed in as a `String`. More information on `NFTMetadataKind` can be found [here](https://github.com/casper-ecosystem/cep-78-enhanced-nft#nftmetadatakind). This parameter may be left empty if metadata kind is set to `Raw(3)`. If the metadata kind is set to `CustomValidated(4)`, it will require a specifically formatted custom schema. This parameter **cannot be changed post installation**. +* `jsonSchema` - The JSON schema for the NFT tokens that will be minted by the NFT contract passed in as a `String`. More information on `NFTMetadataKind` can be found [here](../docs/modalities.md#nftmetadatakind). This parameter may be left empty if metadata kind is set to `Raw(3)`. If the metadata kind is set to `CustomValidated(4)`, it will require a specifically formatted custom schema. This parameter **cannot be changed post installation**. * `nftMetadataKind` - The metadata schema for the NFTs to be minted by the NFT contract. This argument is passed in as a `u8` value and is required at the time of installation. @@ -81,7 +81,7 @@ As with every deploy created by the SDK, you can send it using the `.send(rpcUrl * `burnMode` - The `BurnMode` modality dictates whether minted NFTs can be burned. This optional parameter will allow tokens to be burnt by default. **This parameter cannot be changed once the contract has been installed**. -* `ownerReverseLookupMode` - The `OwnerReverseLookupMode` dictates whether the contract will index ownership of tokens as outlined [here](https://github.com/casper-ecosystem/cep-78-enhanced-nft#the-cep-78-page-system) to allow lookup of owned tokens by account. **This parameter cannot be changed once the contract has been installed**. +* `ownerReverseLookupMode` - The `OwnerReverseLookupMode` dictates whether the contract will index ownership of tokens as outlined [here](../docs/reverse-lookup.md#the-cep-78-page-system) to allow lookup of owned tokens by account. **This parameter cannot be changed once the contract has been installed**. Further information on CEP-78 modality options can be found in the base [cep-78-enhanced-nft](https://github.com/ACStoneCL/cep-78-enhanced-nft) repository on GitHub. diff --git a/docs/modalities.md b/docs/modalities.md index 8cec2901..8d2d355f 100644 --- a/docs/modalities.md +++ b/docs/modalities.md @@ -296,8 +296,8 @@ The `OwnerReverseLookupMode` modality is set at install and determines if a give This modality provides the following options: 1. `NoLookup`: The reporting and receipt functionality is not supported. In this option, the contract instance does not maintain a reverse lookup database of ownership and therefore has more predictable gas costs and greater scaling. -2. `Complete`: The reporting and receipt functionality is supported. Token ownership will be tracked by the contract instance using the system described [here](../README.md#owner-reverse-lookup-functionality). -3. `TransfersOnly`: The reporting and receipt functionality is supported like `Complete`. However, it does not begin tracking until the first transfer. This modality is for use cases where the majority of NFTs are owned by a private minter and only NFT's that have been transferred benefit from reverse lookup tracking. Token ownership will also be tracked by the contract instance using the system described [here](../README.md#owner-reverse-lookup-functionality). +2. `Complete`: The reporting and receipt functionality is supported. Token ownership will be tracked by the contract instance using the system described [here](../docs/reverse-lookup.md#owner-reverse-lookup-functionality). +3. `TransfersOnly`: The reporting and receipt functionality is supported like `Complete`. However, it does not begin tracking until the first transfer. This modality is for use cases where the majority of NFTs are owned by a private minter and only NFT's that have been transferred benefit from reverse lookup tracking. Token ownership will also be tracked by the contract instance using the system described [here](../docs/reverse-lookup.md#owner-reverse-lookup-functionality). Additionally, when set to `Complete`, causes a receipt to be returned by the `mint` or `transfer` entrypoints, which the caller can store in their account or contract context for later reference. diff --git a/docs/tutorials/custom-migration-tutorial.md b/docs/tutorials/custom-migration-tutorial.md index d7f672ce..de42e140 100644 --- a/docs/tutorials/custom-migration-tutorial.md +++ b/docs/tutorials/custom-migration-tutorial.md @@ -8,11 +8,11 @@ This tutorial uses the Casper command-line client to upgrade *and* migrate from - Your v1.0.0 NFT contract instance uses custom NamedKeys for the contract package hash and contract package access URef. - You have the v1.0.0 contract package hash stored under a custom NamedKey in the account that installed the contract. - You have the v1.0.0 contract package access URef stored under a custom NamedKey in the account that installed the contract. -- You understand what is [New in Version 1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/#new-in-version-11) of the CEP-78 Enhanced NFT Standard. +- You understand what is new in [Version 1.1.0](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.0) of the CEP-78 Enhanced NFT Standard. ## Upgrading and Migrating Terminology -The upgrade to version 1.1.1 involves a data migration to a new [page system](https://github.com/casper-ecosystem/cep-78-enhanced-nft#the-cep-78-page-system) tracking token ownership. The usual [upgrade](https://docs.casperlabs.io/dapp-dev-guide/writing-contracts/upgrading-contracts/) process triggers the data migration. For more information, see [Standard Migration Tutorial](standard-migration-tutorial.md#upgrading-and-migrating-terminology). +The upgrade to version 1.1.1 involves a data migration to a new [page system](../reverse-lookup.md#the-cep-78-page-system) tracking token ownership. The usual [upgrade](https://docs.casperlabs.io/dapp-dev-guide/writing-contracts/upgrading-contracts/) process triggers the data migration. For more information, see [Standard Migration Tutorial](standard-migration-tutorial.md#upgrading-and-migrating-terminology). ## Steps to Upgrade to Version 1.1.1 @@ -22,7 +22,7 @@ The `cep-78-wasm` folder contains the `contract.wasm` to send to the network to ### Custom NamedKeys before Migration -The custom migration path assumes that the contract has modified the NamedKey entries created during the v1.0.0. See the example below as well as the [NamedKeyConvention](https://github.com/casper-ecosystem/cep-78-enhanced-nft#namedkeyconventionmode) modality. +The custom migration path assumes that the contract has modified the NamedKey entries created during the v1.0.0. See the example below as well as the [NamedKeyConvention](../modalities.md#namedkeyconventionmode) modality. | NamedKey Pre-Migration | Explanation | |-------------|-------------| @@ -38,8 +38,8 @@ The custom migration path assumes that the contract has modified the NamedKey en When upgrading using the `casper-client`, you must provide four runtime arguments: -- `named_key_convention`: The [NamedKeyConvention](https://github.com/casper-ecosystem/cep-78-enhanced-nft#namedkeyconventionmode) runtime argument as a u8 value equal to 2: `--session-arg "named_key_convention:u8='2'"`. See the [ARG_NAMED_KEY_CONVENTION](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L1991). -- `collection_name`: The collection name specified when the contract was [installed](https://github.com/casper-ecosystem/cep-78-enhanced-nft#installing-the-contract) using the `collection_name` option. See the [contract code](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L93) for details.  +- `named_key_convention`: The [NamedKeyConvention](../modalities.md#namedkeyconventionmode) runtime argument as a u8 value equal to 2: `--session-arg "named_key_convention:u8='2'"`. See the [ARG_NAMED_KEY_CONVENTION](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L1991). +- `collection_name`: The collection name specified when the contract was [installed](./getting-started/full-installation-tutorial.md) using the `collection_name` option. See the [contract code](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L93) for details.  - `hash_key_name`: The custom contract package hash NamedKey as a String. See the [ARG_HASH_KEY_NAME_1_0_0](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L2006). - `access_key_name`: The custom contract package access NamedKey as a String. See the [ARG_ACCESS_KEY_NAME_1_0_0](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L2005). @@ -64,7 +64,7 @@ Here is the full list of required arguments: - `secret-key`: The file name containing the secret key of the account paying for the deploy. - `payment-amount`: The payment for the deploy in motes. - `session-path`: The path to the compiled Wasm on your computer. When using the [cep-78-wasm.tar.gz](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/download/v1.1.1/cep-78-wasm.tar.gz) provided, this would be the path to the `contract.wasm` file. -- `named_key_convention`: Argument that specifies the use of the `V_1_0_standard` [NamedKeyConvention](../README.md#namedkeyconventionmode). +- `named_key_convention`: Argument that specifies the use of the `V_1_0_standard` [NamedKeyConvention](../modalities.md#namedkeyconventionmode). - `collection_name`: Argument that specifies the collection name as a String. - `hash_key_name`: The custom contract package hash NamedKey as a String. - `access_key_name`: The custom contract package access NamedKey as a String. diff --git a/docs/tutorials/standard-migration-tutorial.md b/docs/tutorials/standard-migration-tutorial.md index b321b538..43861807 100644 --- a/docs/tutorials/standard-migration-tutorial.md +++ b/docs/tutorials/standard-migration-tutorial.md @@ -8,11 +8,11 @@ This tutorial uses the Casper command-line client to upgrade *and* migrate from - Your v1.0.0 NFT contract instance uses the contract package hash and contract package access URef created during installation in a **standard way**, without using other NamedKeys to manage the contract package. - You have the v1.0.0 contract package hash stored under the `nft_contract_package` NamedKey in the account that installed the contract. - You have the v1.0.0 contract package access URef stored under the `nft_contract_package_access` NamedKey in the account that installed the contract. -- You understand what is [New in Version 1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/#new-in-version-11) of the CEP-78 Enhanced NFT Standard. +- You understand what is new in [Version 1.1.0](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.0) of the CEP-78 Enhanced NFT Standard. ## Upgrading and Migrating Terminology -An [upgrade](https://docs.casperlabs.io/dapp-dev-guide/writing-contracts/upgrading-contracts/) is the usual manner to release newer versions of a contract inside a contract package. When users install v1.1.* of a CEP-78 contract, they perform an upgrade and a data migration to a new [page system](https://github.com/casper-ecosystem/cep-78-enhanced-nft#the-cep-78-page-system) tracking token ownership. The [OwnerReverseLookupMode](https://github.com/casper-ecosystem/cep-78-enhanced-nft#ownerreverselookupmode) modality introduced in version 1.1.0 allows users to list NFTs by owner. The [README](../README.md) states: +An [upgrade](https://docs.casperlabs.io/dapp-dev-guide/writing-contracts/upgrading-contracts/) is the usual manner to release newer versions of a contract inside a contract package. When users install v1.1.* of a CEP-78 contract, they perform an upgrade and a data migration to a new [page system](../reverse-lookup.md#the-cep-78-page-system) tracking token ownership. The [OwnerReverseLookupMode](../modalities.md#ownerreverselookupmode) modality introduced in version 1.1.0 allows users to list NFTs by owner. The [README](../README.md) states: ``` If you are upgrading a contract from CEP-78 version 1.0 to 1.1, `OwnerReverseLookupMode` will be set to `Complete`, as this was the standard behavior of CEP-78 1.0. In addition to being set to `Complete`, existing records will be migrated into the CEP-78 1.1 format, which will impose a one-time gas cost to cover the migration. @@ -28,7 +28,7 @@ The `cep-78-wasm` folder contains the `contract.wasm` to send to the network to ### Standard NamedKeys before Migration -The standard migration path assumes that the contract uses the NamedKey entries created during the v1.0.0 installation without any modifications. See the example below as well as the [NamedKeyConvention](https://github.com/casper-ecosystem/cep-78-enhanced-nft#namedkeyconventionmode) modality. +The standard migration path assumes that the contract uses the NamedKey entries created during the v1.0.0 installation without any modifications. See the example below as well as the [NamedKeyConvention](../modalities.md#namedkeyconventionmode) modality. | NamedKey Pre-Migration | Explanation | |-------------|-------------| @@ -45,8 +45,8 @@ The standard migration path assumes that the contract uses the NamedKey entries When upgrading using the `casper-client`, you must provide two runtime arguments: -- `named_key_convention`: The [NamedKeyConvention](https://github.com/casper-ecosystem/cep-78-enhanced-nft#namedkeyconventionmode) runtime argument as a u8 value equal to 1: `--session-arg "named_key_convention:u8='1'"`. See the [ARG_NAMED_KEY_CONVENTION](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L1991). -- `collection_name`: The collection name specified when the contract was [installed](https://github.com/casper-ecosystem/cep-78-enhanced-nft#installing-the-contract) using the `collection_name` option. See the [contract code](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L93) for details.  +- `named_key_convention`: The [NamedKeyConvention](../modalities.md#namedkeyconventionmode) runtime argument as a u8 value equal to 1: `--session-arg "named_key_convention:u8='1'"`. See the [ARG_NAMED_KEY_CONVENTION](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L1991). +- `collection_name`: The collection name specified when the contract was [installed](./getting-started/full-installation-tutorial.md) using the `collection_name` option. See the [contract code](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/408db77c3b9ca22752c7f877ea99a01dfca03a7b/contract/src/main.rs#L93) for details.  Here is the `casper-client` command to upgrade and migrate to version 1.1.1 of the NFT collection specified: @@ -67,7 +67,7 @@ Here is the full list of required arguments: - `secret-key`: The file name containing the secret key of the account paying for the deploy. - `payment-amount`: The payment for the deploy in motes. - `session-path`: The path to the compiled Wasm on your computer. When using the [cep-78-wasm.tar.gz](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/download/v1.1.1/cep-78-wasm.tar.gz) provided, this would be the path to the `contract.wasm` file. -- `named_key_convention`: Argument that specifies the use of the `V_1_0_standard` [NamedKeyConvention](../README.md#namedkeyconventionmode). +- `named_key_convention`: Argument that specifies the use of the `V_1_0_standard` [NamedKeyConvention](../modalities.md#namedkeyconventionmode). - `collection_name`: Argument that specifies the collection name as a String. The command returns the deploy hash that you can use to verify whether or not the deploy succeeded. diff --git a/docs/tutorials/token-ownership-tutorial.md b/docs/tutorials/token-ownership-tutorial.md index 1adf02fc..9aa8c921 100644 --- a/docs/tutorials/token-ownership-tutorial.md +++ b/docs/tutorials/token-ownership-tutorial.md @@ -1,6 +1,6 @@ # Token Ownership in Casper NFT Contracts (Release v1.1.1) -This tutorial demonstrates how to check token ownership in CEP-78 NFT contracts, starting with version [v1.1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.1). For this tutorial, the `OwnerReverseLookupMode` modality must be set to `Complete` as described [here](../README.md#ownerreverselookupmode). +This tutorial demonstrates how to check token ownership in CEP-78 NFT contracts, starting with version [v1.1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.1). For this tutorial, the `OwnerReverseLookupMode` modality must be set to `Complete` as described [here](../modalities.md#ownerreverselookupmode). As someone interacting with an NFT contract, you might want to answer the following questions: @@ -27,14 +27,14 @@ The tutorial presents sample accounts, contracts, and NamedKeys to explain, by e ## Prerequisites -- You have installed or upgraded to a CEP-78 contract that uses release v1.1.1, and the `OwnerReverseLookupMode` modality is set to `Complete` as described [here](../README.md#ownerreverselookupmode). +- You have installed or upgraded to a CEP-78 contract that uses release v1.1.1, and the `OwnerReverseLookupMode` modality is set to `Complete` as described [here](../modalities.md#ownerreverselookupmode). - The contract has minted one or more tokens, and you have access to the account or the contract that owns these tokens. - You have experience with the [Casper CEP-78 NFT Standard](https://github.com/casper-ecosystem/cep-78-enhanced-nft/) and the Casper command-line client and know how to interact with a Casper network. -- You understand the [Owner Reverse Lookup Functionality](https://github.com/casper-ecosystem/cep-78-enhanced-nft/#owner-reverse-lookup-functionality) and [CEP-78 Page System](../README.md#the-cep-78-page-system) introduced in [Version 1.1](https://github.com/casper-ecosystem/cep-78-enhanced-nft/#new-in-version-11) of the CEP-78 Enhanced NFT Standard. +- You understand the [Owner Reverse Lookup Functionality](https://github.com/casper-ecosystem/cep-78-enhanced-nft/#owner-reverse-lookup-functionality) and [CEP-78 Page System](../docs/reverse-lookup.md#the-cep-78-page-system) introduced in [Version 1.1.0](https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/tag/v1.1.0) of the CEP-78 Enhanced NFT Standard. ## Method 1 - Querying the Account -In this method of checking token ownership, examine the account or the calling contract's NamedKeys. Look for NamedKeys that use this format: "cep78_*_m_1000_p_#". For more information on this format, read about the [CEP-78 Page System](../README.md#the-cep-78-page-system). This way, you can access the dictionary storing the NFTs directly and retrieve ownership information. +In this method of checking token ownership, examine the account or the calling contract's NamedKeys. Look for NamedKeys that use this format: "cep78_*_m_1000_p_#". For more information on this format, read about the [CEP-78 Page System](../docs/reverse-lookup.md#the-cep-78-page-system). This way, you can access the dictionary storing the NFTs directly and retrieve ownership information. In the following example, the contract minted a small number of NFTs and has the following NamedKey: `cep78_CEP-78-collection_m_1000_p_0`. @@ -91,7 +91,7 @@ To interpret the output, you need to know how the token identifier mode was set ### Tokens Identified by Token ID -If the token identifier mode was set to "Ordinal", the token number is the token ID. In this case, the output above tells us that this account owns the first two tokens in the list. Also, the NamedKey `cep78_CEP-78-collection_m_1000_p_0` indicates that the tokens owned are on "page_0" from the "page_table" dictionary. By doing the math explained [here](../README.md#the-cep-78-page-system) and considering that the token number is the token ID, this account owns tokens 0 and 1. +If the token identifier mode was set to "Ordinal", the token number is the token ID. In this case, the output above tells us that this account owns the first two tokens in the list. Also, the NamedKey `cep78_CEP-78-collection_m_1000_p_0` indicates that the tokens owned are on "page_0" from the "page_table" dictionary. By doing the math explained [here](../docs/reverse-lookup.md#the-cep-78-page-system) and considering that the token number is the token ID, this account owns tokens 0 and 1. > **Note**: What if the named key was `cep78_CEP-78-collection_m_1000_p_11` for the same sample output above? In that case, the account would own tokens on page 11, at index 0 and 1, which would be tokens 11,000 and 11,001. @@ -189,7 +189,7 @@ casper-client get-dictionary-item \ } ``` -The sample response includes only one "parsed" value equal to "true", meaning that one page was allocated at index 0 to track tokens owned by the account specified. In other words, the account with hash "e861226c153eefc0ca48bf29c76bc305235151aebde76257bf9bbacb4fa041f7" owns tokens tracked in the "page_0" dictionary. To understand the page structure further, review how the contract manages storage and token ownership [here](../README.md#the-cep-78-page-system). +The sample response includes only one "parsed" value equal to "true", meaning that one page was allocated at index 0 to track tokens owned by the account specified. In other words, the account with hash "e861226c153eefc0ca48bf29c76bc305235151aebde76257bf9bbacb4fa041f7" owns tokens tracked in the "page_0" dictionary. To understand the page structure further, review how the contract manages storage and token ownership [here](../docs/reverse-lookup.md#the-cep-78-page-system). Since the NFT contract allocated the "page_0" dictionary to track tokens for this account, expect to see a NamedKey called "page_0". Using the URef of the "page_0" dictionary and the account hash, retrieve the token IDs that the account owns. From 691e907de45aad9b7a4d35b7598e314f83460f68 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 1 Mar 2024 23:03:14 +0100 Subject: [PATCH 17/26] Fix link --- docs/tutorials/getting-started/interacting-with-NFTs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index 01e65159..e7d68c75 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -185,7 +185,7 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-
-This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entrypoint to verify the account's balance as shown [below](#invoking-the-balance_of-entry-point). +This command will return a deploy hash that you can query using `casper-client get-deploy`. Querying the deploy allows you to verify execution success, but you will need to use the `balance_of` entrypoint to verify the account's balance as shown [below](#checking-the-balance). ### Transferring NFTs using Wasm From a4e5c3d0cee78f35138f790ee663907b6d4dbb3f Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 1 Mar 2024 23:07:01 +0100 Subject: [PATCH 18/26] Remove tests\wasm link; it only exists when building --- docs/tutorials/getting-started/testing-NFTs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/getting-started/testing-NFTs.md b/docs/tutorials/getting-started/testing-NFTs.md index 5d0bfa23..fe291c2c 100644 --- a/docs/tutorials/getting-started/testing-NFTs.md +++ b/docs/tutorials/getting-started/testing-NFTs.md @@ -20,6 +20,6 @@ To build and run the tests, issue the following command in the project folder: make test ``` -The project contains a [Makefile](../../../Makefile), which is a custom build script that compiles the contract before running tests in _release_ mode. Then, the script copies the `contract.wasm` file to the corresponding version folder in the [tests/wasm](../../../tests/wasm/) directory. In practice, you only need to run the `make test` command during development without building the contract separately. +The project contains a [Makefile](../../../Makefile), which is a custom build script that compiles the contract before running tests in _release_ mode. Then, the script copies the `contract.wasm` file to the corresponding version folder in the `tests/wasm` directory. In practice, you only need to run the `make test` command during development without building the contract separately. This example uses `bash`. If you use a Rust IDE, you must configure it to run the tests. \ No newline at end of file From 520ba67cfbcff1bc38a70eb820ca0383181a87c9 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Fri, 1 Mar 2024 23:21:59 +0100 Subject: [PATCH 19/26] Fix headers --- docs/tutorials/getting-started/quickstart-guide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/getting-started/quickstart-guide.md b/docs/tutorials/getting-started/quickstart-guide.md index cb5bbe5e..0c3eebd8 100644 --- a/docs/tutorials/getting-started/quickstart-guide.md +++ b/docs/tutorials/getting-started/quickstart-guide.md @@ -13,7 +13,7 @@ Before using this guide, ensure you meet the following requirements: - Know how to install a [smart contract](https://docs.casper.network/developers/cli/sending-deploys/) on a Casper network - Hold enough CSPR tokens to pay for transactions -# Setup +## Setup Clone the Casper NFT (CEP-78) [contract repository](https://github.com/casper-ecosystem/cep-78-enhanced-nft/). @@ -55,7 +55,7 @@ casper-client put-deploy --node-address http://localhost:11101/rpc/ \ --session-arg "metadata_mutability:u8='0'" ``` -### Next Steps +## Next Steps Learn to query the contract, perform token transfers, set up approvals, and understand the testing framework. From 1c1eac0d515ca8b6741316ba6d19e71ffffda96a Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 11 Mar 2024 20:22:42 +0100 Subject: [PATCH 20/26] Review feedback for checking balances --- .../getting-started/interacting-with-NFTs.md | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index e7d68c75..d6978f56 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -234,34 +234,37 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net- ## Checking the Balance -The following command invokes the `balance_of_call.wasm` and saves the number of tokens owned under the account's named keys. +To check an account's balance, get the latest state root hash and query the `balances` dictionary given the NFT contract hash and the owner's account hash without the "account-hash-" prefix, as shown below. -- `casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net-1" --payment-amount 5000000000 -k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem --session-path ~/casper/enhanced-nft/client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm` +- `casper-client get-dictionary-item -n http://localhost:11101/rpc` -1. `--session-arg "nft_contract_hash:key='hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796'"` +1. `--state-root-hash f22e8ecfb3d2700d5f902c83da456c32f130b73d0d35037fe89b2d4b4933673f` - The contract hash of the previously installed CEP-78 NFT contract. + The latest state root hash. + +2. `--contract-hash hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796` + + The NFT contract hash. -2. `--session-arg "token_owner:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'"` +3. `--dictionary-name "balances"` - The account hash of the user whose token balance we are checking. + The dictionary tracking the number of tokens for each account hash. -3. `--session-arg "key_name:string='balance'"` +4. `--dictionary-item-key "0ea7998b2822afe5b62b08a21d54c941ad791279b089f3f7ede0d72b477eca34"` - The name for the entry under the `NamedKeys` under which the balance amount will be stored. + The account hash of the user whose token balance we are checking without the `account-hash-` prefix.
-Casper client command without comments +Casper client commands without comments ```bash -casper-client put-deploy -n http://localhost:11101/rpc/ \ ---chain-name "casper-net-1" \ ---payment-amount 5000000000 \ --k ~/casper/casper-node/utils/nctl/assets/net-1/nodes/node-1/keys/secret_key.pem \ ---session-path ~/casper/enhanced-nft/client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm \ ---session-arg "nft_contract_hash:key='hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796'" \ ---session-arg "token_owner:key='account-hash-e70dbca48c2d31bc2d754e51860ceaa8a1a49dc627b20320b0ecee1b6d9ce655'" \ ---session-arg "key_name:string='balance'" +casper-client get-state-root-hash --node-address https://rpc.testnet.casperlabs.io/ + +casper-client get-dictionary-item -n http://localhost:11101/rpc/ \ +--state-root-hash f22e8ecfb3d2700d5f902c83da456c32f130b73d0d35037fe89b2d4b4933673f \ +--contract-hash hash-378a43e38bc5129d8aa3bcd04f5c9a97be73f85b5be574182ac1346f04520796 \ +--dictionary-name "balances" \ +--dictionary-item-key "0ea7998b2822afe5b62b08a21d54c941ad791279b089f3f7ede0d72b477eca34" ```
From 0f52d316715270981d6838923331008b3b310606 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 11 Mar 2024 20:28:51 +0100 Subject: [PATCH 21/26] Updated TOC --- .../getting-started/interacting-with-NFTs.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index d6978f56..fdd69d44 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -13,13 +13,17 @@ This document describes interacting with NFTs on a Casper network using the Rust 1. [Directly Invoking Entrypoints](#directly-invoking-entrypoints) -2. [Transferring NFTs](#transferring-nfts) +2. [Minting NFTs](#minting-nfts) -3. [Approving Another Account](#approving-another-account) +3. [Transferring NFTs](#transferring-nfts) -4. [Minting NFTs](#minting-nfts) +4. [Checking Balances](#checking-balances) -5. [Burning NFTs](#burning-nfts) +5. [Approving an Account](#approving-an-account) + +6. [Burning NFTs](#burning-nfts) + +7. [Next Steps](#next-steps) ## Directly Invoking Entrypoints @@ -232,7 +236,7 @@ casper-client put-deploy -n http://localhost:11101/rpc --chain-name "casper-net- -## Checking the Balance +## Checking Balances To check an account's balance, get the latest state root hash and query the `balances` dictionary given the NFT contract hash and the owner's account hash without the "account-hash-" prefix, as shown below. From ea985bb53207abb5928155e8ec91280997c741a4 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Tue, 12 Mar 2024 14:35:43 +0100 Subject: [PATCH 22/26] Reverting merge updates to the Changelog --- CHANGELOG.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c4e246..4f27994f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,7 +59,6 @@ All notable changes to this project will be documented in this file. The format - Transfer Filter Hook. The transfer filter modality, if enabled, specifies a contract package hash pointing to a contract that will be called when the `transfer` method is invoked on the contract. -- Added the `ACL` option to the `minting_mode` modality. This option allows only whitelisted accounts or contracts to mint tokens. More information can be found [here](./docs/modalities.md#minting). - Added the `ACL` option to the `minting_mode` modality. This option allows only whitelisted accounts or contracts to mint tokens. More information can be found [here](./docs/modalities.md#minting). ## Release 1.3.0 @@ -78,10 +77,9 @@ All notable changes to this project will be documented in this file. The format ### Added -- Added a new modality named `EventsMode` that dictates how the installed instance of CEP-78 will handle the recording of events. Refer to the [README](./docs/modalities.md#eventsmode) for further details - Added a new modality named `EventsMode` that dictates how the installed instance of CEP-78 will handle the recording of events. Refer to the [README](./docs/modalities.md#eventsmode) for further details -- Added the ability for the contract to specify one or more metadata schemas, with the option to further specify optional metadata schemas. Additional required metadatas are specified by `additional_required_metadata`, while additional optional metadata schemas can be specified using `optional_metadata`. Refer to the [`Installing the Contract`](./docs/tutorials/getting-started/full-installation-tutorial.md) section of the README for more information on using these arguments. +- Added the ability for the contract to specify one or more metadata schemas, with the option to further specify optional metadata schemas. Additional required metadatas are specified by `additional_required_metadata`, while additional optional metadata schemas can be specified using `optional_metadata`. Refer to the [`Installing the Contract`](./docs/using-casper-client.md#installing-the-contract) section of the README for more information on using these arguments. - When upgrading from a contract instance, you may now change the `total_token_supply` to a number higher than the current number of minted tokens, but lower than your previous total. The number cannot be zero. More information is available in the upgrade tutorials. @@ -93,7 +91,6 @@ All notable changes to this project will be documented in this file. The format ### Changed -- `OwnerReverseLookupMode` now contains an additional option, `TransfersOnly`, which begins tracking ownership upon transfer. More information can be found [here](./docs/modalities.md#ownerreverselookupmode). - `OwnerReverseLookupMode` now contains an additional option, `TransfersOnly`, which begins tracking ownership upon transfer. More information can be found [here](./docs/modalities.md#ownerreverselookupmode). - Optimized the `set_approval_for_all` entrypoint implementation to reduce gas costs. @@ -117,7 +114,6 @@ All notable changes to this project will be documented in this file. The format - To allow isolation of the additional costs, or tracking individual owners, the reverse lookup mode supports a register entrypoint which is used to register owners prior to minting or receiving a transferred token. In either `Assigned` or `Transferable` mode, this register entrypoint can be called by any party on behalf of another party. - As a result of this change, the previously used `owned_tokens` dictionary is now deprecated. Moving forward, token ownership will be tracked using the `OwnerReverseLookupMode` modality and [CEP-78 Page System](./docs/reverse-lookup.md#the-cep-78-page-system). - - As a result of this change, the previously used `owned_tokens` dictionary is now deprecated. Moving forward, token ownership will be tracked using the `OwnerReverseLookupMode` modality and [CEP-78 Page System](./docs/reverse-lookup.md#the-cep-78-page-system). ### Changed @@ -128,4 +124,4 @@ All notable changes to this project will be documented in this file. The format - **If an account attempts to install a second CEP-78 contract with the same name, it will overwrite the access rights and render the first instance unusable.** -[Keep a Changelog]: https://keepachangelog.com/en/1.0.0 +[Keep a Changelog]: https://keepachangelog.com/en/1.0.0 \ No newline at end of file From f0661128b190fd24e1761e6afe7b85b2a0f980d3 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Tue, 12 Mar 2024 14:43:33 +0100 Subject: [PATCH 23/26] Remove explanation covered in the contract writing docs --- .../full-installation-tutorial.md | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/docs/tutorials/getting-started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md index 8ca14ac7..f09db94e 100644 --- a/docs/tutorials/getting-started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -74,50 +74,6 @@ There are four steps to follow when you intend to create your implementation of 3. Compile the customized code to Wasm. 4. Send the customized Wasm as a deploy to a Casper network. -### Required Crates - -This tutorial applies to the Rust implementation of the Casper NFT standard, which requires the following Casper crates: - -- [casper_contract](https://docs.rs/casper-contract/latest/casper_contract/index.html) - A Rust library for writing smart contracts on Casper networks -- [casper_types](https://docs.rs/casper-types/latest/casper_types/) - Types used to allow the creation of Wasm contracts and tests for use on Casper networks - -Here is the code snippet that imports those crates: - -```rust -use casper_contract::{ - contract_api::{ - runtime::{self, call_contract, revert}, - storage::{self}, - }, - unwrap_or_revert::UnwrapOrRevert, -}; -use casper_types::{ - contracts::NamedKeys, runtime_args, CLType, CLValue, ContractHash, ContractPackageHash, - EntryPoint, EntryPointAccess, EntryPointType, EntryPoints, Key, KeyTag, Parameter, RuntimeArgs, - Tagged, -}; -``` - -**Note**: In Rust, the keyword `use` is like an include statement in C/C++. - -The contract code defines additional modules in the `contract/src` folder: - -```rust -mod constants; -mod error; -mod events; -mod metadata; -mod modalities; -mod utils; -``` - -- `constants` - Constant values required to run the contract code -- `error` - Errors related to the NFT contract -- `events` - A library for contract-emitted events -- `metadata` - Module handling the contract's metadata and corresponding dictionary -- `modalities` - Common expectations around contract usage and behavior -- `utils` - Utility and helper functions to run the contract code - ### Initialization Flow Initializing the contract happens through the `call() -> install_contract() -> init()` functions inside the [main.rs](../../../contract/src/main.rs) contract file. The `init()` function reads the runtime arguments and defines parameters such as `collection_name`, `collection_symbol`, and `total_token_supply`, among the other required and optional arguments described in the [README](../../../README.md#required-runtime-arguments). From e54f51b6592b0b6d7c8cd3f4c175b1b3ff02de3d Mon Sep 17 00:00:00 2001 From: ipopescu Date: Tue, 12 Mar 2024 14:52:09 +0100 Subject: [PATCH 24/26] Add back a brief explanation about the imports --- .../full-installation-tutorial.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/getting-started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md index f09db94e..e34e58f2 100644 --- a/docs/tutorials/getting-started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -10,7 +10,7 @@ Information on the modalities used throughout this installation process can be f - [Prerequisites](#prerequisites) - [Building the Contract and Tests](#building-the-contract-and-tests) 2. [Reviewing the Contract Implementation](#reviewing-the-contract-implementation) - - [Required Crates](#required-crates) + - [Crates and Modules](#crates-and-modules) - [Initialization Flow](#Initialization-flow) - [Contract Entrypoints](#contract-entrypoints) 3. [Installing the Contract](#installing-the-contract) @@ -74,6 +74,22 @@ There are four steps to follow when you intend to create your implementation of 3. Compile the customized code to Wasm. 4. Send the customized Wasm as a deploy to a Casper network. +### Crates and Modules + +The contract implementation starts by importing the following essential Casper crates: + +- [casper_contract](https://docs.rs/casper-contract/latest/casper_contract/index.html) - A Rust library for writing smart contracts on Casper networks +- [casper_types](https://docs.rs/casper-types/latest/casper_types/) - Types used to allow the creation of Wasm contracts and tests for use on Casper networks + +The contract code defines additional modules in the `contract/src` folder: + +- `constants` - Constant values required to run the contract code +- `error` - Errors related to the NFT contract +- `events` - A library for contract-emitted events +- `metadata` - A module handling the contract's metadata and corresponding dictionary +- `modalities` - Common expectations around contract usage and behavior +- `utils` - Utility and helper functions to run the contract code + ### Initialization Flow Initializing the contract happens through the `call() -> install_contract() -> init()` functions inside the [main.rs](../../../contract/src/main.rs) contract file. The `init()` function reads the runtime arguments and defines parameters such as `collection_name`, `collection_symbol`, and `total_token_supply`, among the other required and optional arguments described in the [README](../../../README.md#required-runtime-arguments). From c5f490a38b3d640629443c3d41102a667bb5860c Mon Sep 17 00:00:00 2001 From: ipopescu Date: Tue, 12 Mar 2024 16:13:31 +0100 Subject: [PATCH 25/26] Add missing entrypoints and an important note --- .../full-installation-tutorial.md | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/getting-started/full-installation-tutorial.md b/docs/tutorials/getting-started/full-installation-tutorial.md index e34e58f2..be2bbf39 100644 --- a/docs/tutorials/getting-started/full-installation-tutorial.md +++ b/docs/tutorials/getting-started/full-installation-tutorial.md @@ -10,7 +10,7 @@ Information on the modalities used throughout this installation process can be f - [Prerequisites](#prerequisites) - [Building the Contract and Tests](#building-the-contract-and-tests) 2. [Reviewing the Contract Implementation](#reviewing-the-contract-implementation) - - [Crates and Modules](#crates-and-modules) + - [Included Crates and Modules](#included-crates-and-modules) - [Initialization Flow](#Initialization-flow) - [Contract Entrypoints](#contract-entrypoints) 3. [Installing the Contract](#installing-the-contract) @@ -74,7 +74,7 @@ There are four steps to follow when you intend to create your implementation of 3. Compile the customized code to Wasm. 4. Send the customized Wasm as a deploy to a Casper network. -### Crates and Modules +### Included Crates and Modules The contract implementation starts by importing the following essential Casper crates: @@ -96,23 +96,36 @@ Initializing the contract happens through the `call() -> install_contract() -> i ### Contract Entrypoints -This section briefly explains the essential entrypoints used in the Casper NFT contract. To see their full implementation, refer to the [main.rs](../../../contract/src/main.rs) contract file. For further questions, contact the Casper support team via the [Discord channel](https://discord.com/invite/casperblockchain). The following entrypoints are listed as they are found in the code. +This section briefly explains the essential entrypoints used in the Casper NFT contract. To see their full implementation, refer to the [main.rs](../../../contract/src/main.rs) contract file. For further questions, contact the Casper support team via the [Discord channel](https://discord.com/invite/casperblockchain). - [**approve**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1002) - Allows a spender to transfer up to an amount of the owners’s tokens - [**balance_of**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1616) - Returns the token balance of the owner - [**burn**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L874) - Burns tokens, reducing the total supply - [**get_approved**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1728) - Returns the hash of the approved account for a specified token identifier - [**init**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L81) - Sets the collection name, symbol, and total token supply; initializes the allow minting setting, minting mode, ownership mode, NFT kind, holder mode, whitelist mode and contract whitelist, JSON schema, receipt name, identifier mode, and burn mode. This entrypoint can only be called once when the contract is installed on the network +- [**is_approved_for_all**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1328) - Returns yes if an account is approved as an operator for a token owner - [**metadata**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1675) - Returns the metadata associated with a token identifier - [**mint**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L619) - Mints additional tokens if minting is allowed, increasing the total supply - [**owner_of**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1636) - Returns the owner for a specified token identifier +- [**register_owner**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L2159) - Register an owner for a specified token identifier. Works when the *OwnerReverseLookupMode* is set to *Complete* +- [**revoke**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1138) - Revokes an account that was approved for an identified token transfer. The *OwnershipMode* must be set to *Transferable* - [**set_approval_for_all**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1254) - Allows a spender to transfer all of the owner's tokens - [**set_token_metadata**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1773) - Sets the metadata associated with a token identifier - [**set_variables**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L496) - Allows the user to set any combination of variables simultaneously, defining which variables are mutable or immutable -- [**transfer**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1359) - Transfers tokens from the token owner to a specified account. The transfer will succeed if the caller is the token owner or an approved operator. The transfer will fail if the OwnershipMode is set to Minter or Assigned +- [**transfer**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1359) - Transfers tokens from the token owner to a specified account. The transfer will succeed if the caller is the token owner or an approved operator. The *OwnershipMode* must be set to *Transferable* +- [**updated_receipts**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L2111) - Allows an owner of one or more NFTs held by the contract instance to attain up to date receipt information for the NFTs they currently own. Works when the *OwnerReverseLookupMode* is set to *Complete* There is also the [**migrate**](https://github.com/casper-ecosystem/cep-78-enhanced-nft/blob/440bff44277ab5fd295f37229fe92278339d3753/contract/src/main.rs#L1975) entrypoint, which was needed only for migrating a 1.0 version of the NFT contract to version 1.1. +**IMPORTANT**: The following entrypoints return data using `runtime::ret`, which is useful mainly if the entrypoint caller is a contract: + +- `mint` (with *OwnerReverseLookupMode* set to *Complete*) +- `transfer` (with *OwnerReverseLookupMode* set to *TransfersOnly*) +- `balance_of` +- `is_approved_for_all` +- `owner_of` +- `metadata` + ## Installing the Contract Installing the enhanced NFT contract to global state requires using a [Deploy](https://docs.casper.network/developers/dapps/sending-deploys/). But before proceeding with the installation, verify the network state and the status of the account that will send the installation deploy. From 4b55cb651703c2e111cb5c0bed7e8f4dc9b8fd52 Mon Sep 17 00:00:00 2001 From: ipopescu Date: Mon, 25 Mar 2024 12:50:36 +0100 Subject: [PATCH 26/26] Note about token_hash during minting --- docs/tutorials/getting-started/interacting-with-NFTs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/tutorials/getting-started/interacting-with-NFTs.md b/docs/tutorials/getting-started/interacting-with-NFTs.md index fdd69d44..28805dbe 100644 --- a/docs/tutorials/getting-started/interacting-with-NFTs.md +++ b/docs/tutorials/getting-started/interacting-with-NFTs.md @@ -88,6 +88,8 @@ Below is an example of a `casper-client` command that uses the `mint` entrypoint Metadata describing the NFT to be minted, passed in as a `string`. +**Note**: If the `identifier_mode` was set to hash (1) during installation, the `token_hash` runtime argument needs to be specified during minting. Since you already know the NFT's identifier, you can easily query the NFT's `meta_data`, which is a very useful feature. This example uses an ordinal (0) `identifier_mode`. +
Casper client command without comments