From 79219d9f2c4a35ecfebcfc2ac6ba5abf2f6c4721 Mon Sep 17 00:00:00 2001 From: Clay Murphy <114445310+clay-aptos@users.noreply.github.com> Date: Tue, 13 Dec 2022 13:24:40 -0600 Subject: [PATCH] Begin porting Move Workshop #1 to Aptos.dev (#5817) * Begin porting Move Workshop #1 to Aptos.dev * Refine private key step * Move TODOs to issue for tracking * Continue building out prerequisites and mint NFT steps Co-authored-by: Clay Murphy --- .../docs/guides/move-guides/index.md | 9 ++ .../docs/guides/move-guides/mint-nft-cli.md | 108 ++++++++++++++++++ developer-docs-site/sidebars.js | 1 + 3 files changed, 118 insertions(+) create mode 100644 developer-docs-site/docs/guides/move-guides/mint-nft-cli.md diff --git a/developer-docs-site/docs/guides/move-guides/index.md b/developer-docs-site/docs/guides/move-guides/index.md index baba8eca814b1..b9311ea9a9d3f 100644 --- a/developer-docs-site/docs/guides/move-guides/index.md +++ b/developer-docs-site/docs/guides/move-guides/index.md @@ -5,6 +5,14 @@ slug: "aptos-move-guides" # Write Smart Contracts with Move +To efficiently write smart contracts in Aptos, we recommend you first: + +1. Learn Move concepts +1. Understand Aptos security +1. Create a collection +1. Create an NFT +1. Create resource account + ## Aptos Move guides Start here to learn how the Move language works on the Aptos blockchain. @@ -14,6 +22,7 @@ Start here to learn how the Move language works on the Aptos blockchain. - ### [How Base Gas Works](../../concepts/base-gas.md) - ### [Interact with the Move VM](../interacting-with-the-blockchain.md) - ### [Your First Move module](../../tutorials/first-move-module.md) +- ### [Mint NFT with Aptos CLI](./mint-nft-cli.md) - ### [Upgrading Move Code](upgrading-move-code.md) - ### [Aptos Move Examples](https://github.com/aptos-labs/aptos-core/tree/main/aptos-move/move-examples) diff --git a/developer-docs-site/docs/guides/move-guides/mint-nft-cli.md b/developer-docs-site/docs/guides/move-guides/mint-nft-cli.md new file mode 100644 index 0000000000000..df0793ab50a9e --- /dev/null +++ b/developer-docs-site/docs/guides/move-guides/mint-nft-cli.md @@ -0,0 +1,108 @@ +--- +title: "Mint an NFT with Aptos CLI" +slug: "mint-nft-cli" +--- + +# Mint an NFT + +## Prerequisites + +This tutorial assumes you have: + +* a GitHub account +* the GitHub CLI +* the Aptos CLI (installed below) + +## Mint with the Aptos CLI + +Now that you are starting to write smart contracts with Move, let's create our first NFT with the Aptos CLI. + +1. [Install the Aptos CLI](../../cli-tools/aptos-cli-tool/install-aptos-cli.md) and note its [many uses](../../cli-tools/aptos-cli-tool/use-aptos-cli.md) for later if you haven't experienced its goodness already. + +1. Create an account on Aptos testnet by running the following command and selecting `testnet`: +```shell +aptos init --profile nft-receiver +``` + +1. When prompted, select `testnet` by entering it: + +```shell +Configuring for profile nft-receiver +Choose network from [devnet, testnet, mainnet, local, custom | defaults to devnet] +testnet +``` + +1. When prompted for your private key, hit enter to generate a new key: +```shell +Enter your private key as a hex literal (0x...) [Current: None | No input: Generate new key (or keep one if present)] +``` + +1. Receive output resembling: +```shell +No key given, generating key... +Account blah does not exist, you will need to create and fun the account through a community faucet e.g. https://aptoslabs.com/testnet-faucet, or by transferring funds from another account + +--- +Aptos CLI is now set up for account blah as profile nft-receiver! Run `aptos --help` for more information about commands +{ + "Result": "Success" +} +➜ devel +``` + +1. Note *blah* above is a placeholder for your private key. Record it someplace safe. + +1. Mint the NFT: + +```shell +aptos move run --function-id 8cdf69c8c93fee36ed83f8882908060c1335ed39a827c08dbb506b46237e88fb::minting::mint_nft --profile nft-receiver +``` + +1. When asked, `Do you want to submit a transaction for a range of...?`, enter: `yes` + +1. Receive results resembling: + +```shell +{ + "Result": { + "transaction_hash": "0x9dc5c20f45a06d0cc621bf12610caa5b3c0797ac181c3339248b48ab0f0fcba2", + "gas_used": 3917, + "gas_unit_price": 100, + "sender": "7d69283af198b1265d17a305ff0cca6da1bcee64d499ce5b35b659098b3a82dc", + "sequence_number": 13, + "success": true, + "timestamp_us": 1668045908262170, + "version": 341215563, + "vm_status": "Executed successfully" + } +} +*/ +``` + +## Find the NFT in your Petra wallet + +1. Run `more ~/.aptos/config.yaml` to see the `nft-receiver` private key and then copy it. + +1. Install the [Petra Wallet](../../guides/install-petra-wallet.md) Chrome extension. + +1. Select the [Testnet network](https://petra.app/docs/use) in the wallet via *Petra settings > Network > Testnet*. + +1. Use your testnet coins to send a transaction and mint an NFT. Obtain more and connect your wallet to the faucet at: https://aptoslabs.com/testnet-faucet + +1. Go to *Petra > Settings > Switch account > Add Account > Import private key*. + +1. Paste the `nft-receiver` private key there. + +1. Go to *Petra > Settings > Network > Testnet*. + +1. Click **Library** at bottom. + +1. See the NFT in your wallet. + +## Deploy the NFT contract + +Now you can add this smart contract to the Aptos network: + +1. Check out and review the [NFT Tutorial](https://github.com/aptos-labs/nft-tutorial) source code. + +1. Explore the `mint_nft` function in [`minting.move`](https://github.com/aptos-labs/nft-tutorial/blob/main/sources/minting.move). diff --git a/developer-docs-site/sidebars.js b/developer-docs-site/sidebars.js index a642a514d9b29..ca58e286fadae 100644 --- a/developer-docs-site/sidebars.js +++ b/developer-docs-site/sidebars.js @@ -134,6 +134,7 @@ const sidebars = { "concepts/base-gas", "guides/interacting-with-the-blockchain", "tutorials/first-move-module", + "guides/move-guides/mint-nft-cli", "guides/move-guides/upgrading-move-code", ], },