diff --git a/docs/guides/hardhat-walkthrough/deploy-custom-lsp7.md b/docs/contracts/getting-started.md similarity index 51% rename from docs/guides/hardhat-walkthrough/deploy-custom-lsp7.md rename to docs/contracts/getting-started.md index 036742e644..34e3883fac 100644 --- a/docs/guides/hardhat-walkthrough/deploy-custom-lsp7.md +++ b/docs/contracts/getting-started.md @@ -1,13 +1,120 @@ --- -sidebar_label: Deploy our custom LSP7 contract -sidebar_position: 3 +sidebar_label: Getting Started +title: Getting Started +sidebar_position: 2 --- -# Deploy your contract +This page will guide you through the process of: -Following the previous guide (["Create a custom LSP7 contract"](./create-custom-lsp7.md)), we are now ready to deploy our contract on the LUKSO Testnet network! +- setting up an [Hardhat](https://hardhat.org/) installation (using TypeScript) +- adding the [`@lukso/lsp-smart-contracts`](https://www.npmjs.com/package/@lukso/lsp-smart-contracts) package (using version 0.11.0-rc.1) +- creating a basic `LSP7DigitalAsset` contract +- and deploying it on [LUKSO Testnet](../../networks/testnet/parameters). -## Deploy the contract on LUKSO Testnet +### Create Hardhat project + +The first thing to do is to [create a new Hardhat project](https://hardhat.org/hardhat-runner/docs/getting-started#quick-start) that will use TypeScript: + +```bash title="Setup new hardhat project" +mkdir lukso-app +cd lukso-app +npx hardhat +# select 'Create a TypeScript project' and +# use the default value for the rest of the setup +``` + +Once finished, you have a working Hardhat setup! + +### Install packages & setup tools + +To work in the best condition possible, we will install libraries that includes tools, helpers and the [`@lukso/lsp-smart-contracts`](https://www.npmjs.com/package/@lukso/lsp-smart-contracts) package. + +#### Install dependencies + +```bash +npm i -D dotenv +npm i -s @lukso/lsp-smart-contracts@0.11.0-rc.1 +``` + +#### Add a build script in your package.json + +Update your `package.json` with the following: + +```json title="package.json" +"scripts": { + "build": "hardhat compile --force --show-stack-traces" +}, +``` + +#### Create a .env file + +Create a new file at the root of your project called `.env` with the following content: + +:::warning + +The `.env` file contains sensitive values such as PRIVATE_KEY. Do not commit it to your source code repository! + +::: + +:::note + +We will populate the values of the `.env` file later. + +::: + +```text title=".env" +PRIVATE_KEY= +UP_ADDR= +``` + +We now have a base Hardhat setup that we can use to develop and deploy our smart contracts. + + +## Create a custom LSP7 Token contract + +We will now create a custom [LSP7 Digital Asset contract](../standards/nft-2.0/LSP7-Digital-Asset.md). This contract will extend [`LSP7Mintable`](./contracts/LSP7DigitalAsset/presets/LSP7Mintable.md) & [LSP7Burnable](./contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md) (to allow burning tokens). We will also pre-mint 20k tokens to the owner of the contract (the deployer). +To do that, delete the `Lock.sol` contract in the `contracts/` folder, then create a new file named `MyCustomToken.sol` with the following content: + +```solidity title="contracts/MyCustomToken.sol" +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.9; + +import "@lukso/lsp-smart-contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol"; +import "@lukso/lsp-smart-contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol"; + +contract CustomToken is LSP7Mintable, LSP7Burnable { + // parameters for LSP7Mintable constructor are: + // token name, + // token symbol, + // token owner, + // boolean isNonDivisible + // for more informations, check https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-7-DigitalAsset.md + constructor() LSP7Mintable("My Custom Token", "MCT", msg.sender, false) { + mint(msg.sender, 20000 * 10**decimals(), true, '0x' ); + } +} +``` + +### 🍭 Bonus: create a MockContract to generate the UniversalProfile type + +In order to deploy this Custom LSP7 contract, we will interact with a UniversalProfile. We can enhance the developer experience by generating the types for a `UniversalProfile` contract. +To do that, you can create a `MockContract.sol` file in the `contracts/` file with the following content: + +```solidity title="contracts/MyCustomToken.sol" +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.9; +import {UniversalProfile} from '@lukso/lsp-smart-contracts/contracts/UniversalProfile.sol'; +``` + +We are now ready to build our contracts using the command: + +```bash +npm run build +``` + +## Deploy our LSP7 Token contract on LUKSO Testnet + +We are now ready to deploy our contract on the [**LUKSO Testnet network**](../networks/testnet/parameters.md)! In order to deploy the contract, we will have to update the `hardhat.config.ts` and create a deploy script. Let's go! @@ -42,7 +149,7 @@ We will create a script to deploy the smart contract to the LUKSO Testnet networ #### Deploy using a Universal Profile (Recommended) -In this chapter, we are going to deploy our contract using our Universal Profile. First thing is to [Install the UP browser extension](../../guides/browser-extension/install-browser-extension.md). Once installed, we will retrieve the information we need: +In this chapter, we are going to deploy our contract using our Universal Profile. First thing is to [Install the UP browser extension](../guides/browser-extension/install-browser-extension.md). Once installed, we will retrieve the information we need: - Click on the extension - Click on the cogwheel ⚙️ at the top right corner, then select "reveal private keys" @@ -52,7 +159,7 @@ In this chapter, we are going to deploy our contract using our Universal Profile :::note -The `privateKey` coming from your UP extension is the private key of the EOA that controls your UP (more information about controllers can be found in the [Key Manager](../../standards/universal-profile/lsp6-key-manager.md) page). You can find the associated address in the extension if you click on the controller tab > UP Extension. This address will need to be funded using the [Testnet Faucet](https://faucet.testnet.lukso.network/). +The `privateKey` coming from your UP extension is the private key of the EOA that controls your UP (more information about controllers can be found in the [Key Manager](../standards/universal-profile/lsp6-key-manager.md) page). You can find the associated address in the extension if you click on the controller tab > UP Extension. This address will need to be funded using the [Testnet Faucet](https://faucet.testnet.lukso.network/). ::: diff --git a/docs/contracts/interface-ids.md b/docs/contracts/interface-ids.md index d20ff55ad6..98d5b354be 100644 --- a/docs/contracts/interface-ids.md +++ b/docs/contracts/interface-ids.md @@ -1,6 +1,5 @@ --- title: Interfaces IDs -sidebar_position: 2 --- import InterfaceIdsTable from "./\_interface_ids_table.mdx"; diff --git a/docs/guides/hardhat-walkthrough/_category_.yml b/docs/guides/hardhat-walkthrough/_category_.yml deleted file mode 100644 index e800218d44..0000000000 --- a/docs/guides/hardhat-walkthrough/_category_.yml +++ /dev/null @@ -1,3 +0,0 @@ -label: '✏️ Hardhat Walkthrough' -collapsed: true -position: 3 diff --git a/docs/guides/hardhat-walkthrough/create-custom-lsp7.md b/docs/guides/hardhat-walkthrough/create-custom-lsp7.md deleted file mode 100644 index bb3436565c..0000000000 --- a/docs/guides/hardhat-walkthrough/create-custom-lsp7.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -sidebar_label: Create a custom LSP7 contract -sidebar_position: 2 ---- - -# Create a custom LSP7 contract - -Following the previous guide on ["How to setup a hardhat base setup"](./hardhat-base-setup.md), we will now create a custom [LSP7 contract](../../standards/nft-2.0/LSP7-Digital-Asset.md). - -This contract will extend LSP7Mintable & [LSP7Burnable](../../contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.md) (to allow burning tokens). We will also premint 20k tokens to the owner of the contract (the deployer). -To do that, delete the `Lock.sol` contract in the `contracts/` folder, then create a new file named `MyCustomToken.sol` with the following content: - -```solidity title="contracts/MyCustomToken.sol" -// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.9; - -import "@lukso/lsp-smart-contracts/contracts/LSP7DigitalAsset/presets/LSP7Mintable.sol"; -import "@lukso/lsp-smart-contracts/contracts/LSP7DigitalAsset/extensions/LSP7Burnable.sol"; - -contract CustomToken is LSP7Mintable, LSP7Burnable { - // parameters for LSP7Mintable constructor are: - // token name, - // token symbol, - // token owner, - // boolean isNonDivisible - // for more informations, check https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-7-DigitalAsset.md - constructor() LSP7Mintable("My Custom Token", "MCT", msg.sender, false) { - mint(msg.sender, 20000 * 10**decimals(), true, '0x' ); - } -} -``` - -## Bonus: Create a MockContract to generate the UniversalProfile type - -In order to deploy this Custom LSP7 contract, we will interact with a UniversalProfile. We can enhance the developer experience by generating the types for a `UniversalProfile` contract. -To do that, you can create a `MockContract.sol` file in the `contracts/` file with the following content: - -```solidity title="contracts/MyCustomToken.sol" -// SPDX-License-Identifier: Apache-2.0 -pragma solidity ^0.8.9; -import {UniversalProfile} from '@lukso/lsp-smart-contracts/contracts/UniversalProfile.sol'; -``` - -We are now ready to build our contracts using the command: - -```bash -npm run build -``` diff --git a/docs/guides/hardhat-walkthrough/hardhat-base-setup.md b/docs/guides/hardhat-walkthrough/hardhat-base-setup.md deleted file mode 100644 index 6f72e7d51d..0000000000 --- a/docs/guides/hardhat-walkthrough/hardhat-base-setup.md +++ /dev/null @@ -1,71 +0,0 @@ ---- -sidebar_label: Hardhat basic setup -sidebar_position: 1 ---- - -# Setup your Hardhat project - -In this article will guide you through the process of: - -- setting up an [Hardhat](https://hardhat.org/) installation (using TypeScript) -- adding the [`@lukso/lsp-smart-contracts`](https://www.npmjs.com/package/@lukso/lsp-smart-contracts) package (using version 0.11.0-rc.1) -- creating a basic LSP7 contract -- and deploying it on [LUKSO Testnet](../../networks/testnet/parameters). - -## Create Hardhat project - -The first thing to do is to create a new Hardhat project that will use TypeScript: - -```bash title="Setup new hardhat project" -mkdir lukso-app -cd lukso-app -npx hardhat -# select 'Create a TypeScript project' and -# use the default value for the rest of the setup -``` - -Once finished, you have a working Hardhat setup! - -## Install packages & setup tools - -To work in the best condition possible, we will install libraries that includes tools, helpers and the [`@lukso/lsp-smart-contracts`](https://www.npmjs.com/package/@lukso/lsp-smart-contracts) package. - -### Install dependencies - -```bash -npm i -D dotenv -npm i -s @lukso/lsp-smart-contracts@0.11.0-rc.1 -``` - -### Add a build script in your package.json - -Update your `package.json` with the following: - -```json title="package.json" -"scripts": { - "build": "hardhat compile --force --show-stack-traces" -}, -``` - -### Create a .env file - -Create a new file at the root of your project called `.env` with the following content: - -:::warning - -The `.env` file contains sensitive values such as PRIVATE_KEY. Do not commit it to your source code repository! - -::: - -:::note - -We will populate the values of the `.env` file later. - -::: - -```text title=".env" -PRIVATE_KEY= -UP_ADDR= -``` - -We now have a base Hardhat setup that we can use to develop and deploy our smart contracts. diff --git a/docusaurus.config.js b/docusaurus.config.js index 628b05e08b..47aab21670 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -151,6 +151,18 @@ module.exports = { from: '/standards/standards-roadmap', to: '/standards/introduction', }, + { + from: '/guides/hardhat-walkthrough/hardhat-base-setup', + to: '/contracts/getting-started', + }, + { + from: '/guides/hardhat-walkthrough/create-custom-lsp7', + to: '/contracts/getting-started', + }, + { + from: '/guides/hardhat-walkthrough/deploy-custom-lsp7', + to: '/contracts/getting-started', + }, ], }, ], diff --git a/sidebars.js b/sidebars.js index 410fdf0553..4e03a5b663 100644 --- a/sidebars.js +++ b/sidebars.js @@ -15,12 +15,12 @@ module.exports = { guidesSidebar: [{ type: 'autogenerated', dirName: 'guides' }], contractsSidebar: [ 'contracts/introduction', - 'contracts/interface-ids', + 'contracts/getting-started', // divider for the main smart contracts { type: 'html', value: '
', defaultStyle: false }, { type: 'category', - label: '📑 Smart Contracts', + label: 'Smart Contracts', collapsible: true, collapsed: false, items: [ @@ -30,13 +30,13 @@ module.exports = { }, ], }, - // divider for the Contracts ABI Technical references + // divider for the Contracts ABI and Libraries Technical references { type: 'html', value: '
', defaultStyle: false }, { type: 'category', label: '📑 ABI Technical Reference', collapsible: true, - collapsed: false, + collapsed: true, items: [ { type: 'autogenerated', @@ -44,13 +44,11 @@ module.exports = { }, ], }, - // divider for the Libraries Technical references - { type: 'html', value: '
', defaultStyle: false }, { type: 'category', label: '📒 Solidity Libraries', collapsible: true, - collapsed: false, + collapsed: true, items: [ { type: 'autogenerated', @@ -58,6 +56,9 @@ module.exports = { }, ], }, + // divider for the Libraries Technical references + { type: 'html', value: '
', defaultStyle: false }, + 'contracts/interface-ids', ], toolsSidebar: [ 'tools/getting-started',