From 0969d45767515389488e68fc15105799c011e747 Mon Sep 17 00:00:00 2001 From: Joshua Fernandes Date: Mon, 28 Aug 2023 08:36:01 +1000 Subject: [PATCH 1/5] migrate truffle to hardhat Signed-off-by: Joshua Fernandes --- .../how-to/configure/free-gas.md | 14 +- docs/private-networks/how-to/index.md | 2 +- docs/private-networks/tutorials/quickstart.md | 241 +++++++----------- .../public-networks/how-to/develop/hardhat.md | 64 +++++ .../public-networks/how-to/develop/truffle.md | 65 ----- 5 files changed, 170 insertions(+), 216 deletions(-) create mode 100644 docs/public-networks/how-to/develop/hardhat.md delete mode 100644 docs/public-networks/how-to/develop/truffle.md diff --git a/docs/private-networks/how-to/configure/free-gas.md b/docs/private-networks/how-to/configure/free-gas.md index 950ab0f1db6..9eccfd2666d 100644 --- a/docs/private-networks/how-to/configure/free-gas.md +++ b/docs/private-networks/how-to/configure/free-gas.md @@ -34,7 +34,7 @@ When gas is free, limiting block and contract sizes is less important. In free g ### 1. Set the block size -If you want to remove gas from consideration and don't mind blocks potentially taking longer to create, in the genesis file set the block size limit (measured in gas) to the maximum accepted by Truffle (`0x1fffffffffffff`). In the genesis file, specify `gasLimit` following the `config` key. +If you want to remove gas from consideration and don't mind blocks potentially taking longer to create, in the genesis file set the block size limit (measured in gas) to the maximum accepted by Hardhat (`0x1fffffffffffff`). In the genesis file, specify `gasLimit` following the `config` key. ```json { @@ -107,21 +107,21 @@ If your network is configured to use the `londonBlock` or a later hard fork, the } ``` -## Configure free gas in Truffle +## Configure free gas in Hardhat -If using Truffle to develop on your free gas network, you also need to configure free gas in Truffle. +If using Hardhat to develop on your free gas network, you also need to configure free gas in Hardhat. -Like setting block and contract size limits to their maximum values for Besu, set the transaction gas limit in Truffle to the maximum possible. +Like setting block and contract size limits to their maximum values for Besu, set the transaction gas limit in Hardhat to the maximum possible. :::info -Besu does not support private key management. To use Besu with Truffle, you must configure a [Truffle wallet](../../../public-networks/how-to/develop/truffle.md). +Besu does not support private key management. To use Besu with Hardhat, you must configure a [Hardhat wallet](../../../public-networks/how-to/develop/hardhat.md). ::: -### Update `truffle-config.js` +### Update `hardhat.config.js` -Update the `truffle-config.js` file: +Update the `hardhat.config.js` file: 1. Set the gas price to zero. diff --git a/docs/private-networks/how-to/index.md b/docs/private-networks/how-to/index.md index ae5ae0ada06..9884ebccd56 100644 --- a/docs/private-networks/how-to/index.md +++ b/docs/private-networks/how-to/index.md @@ -30,7 +30,7 @@ The following features are shared with [public networks](../../public-networks/i - [Manage JVM memory](../../public-networks/how-to/configure-jvm/manage-memory.md) - [Use Java Flight Recorder](../../public-networks/how-to/configure-jvm/java-flight-recorder.md) - Develop dapps: - - [Use Truffle](../../public-networks/how-to/develop/truffle.md) + - [Use Hardhat](../../public-networks/how-to/develop/hardhat.md) - [Use client libraries](../../public-networks/how-to/develop/client-libraries.md) - Troubleshoot: - [Use EVM tool](../../public-networks/how-to/troubleshoot/evm-tool.md) diff --git a/docs/private-networks/tutorials/quickstart.md b/docs/private-networks/tutorials/quickstart.md index d89b5d31a63..348fac5fa2d 100644 --- a/docs/private-networks/tutorials/quickstart.md +++ b/docs/private-networks/tutorials/quickstart.md @@ -30,7 +30,7 @@ This tutorial runs a private network suitable for education or demonstration pur - Docker desktop configured to use the WSL2-based engine - [Docker and Docker Compose](https://docs.docker.com/compose/install/) - [Node.js](https://nodejs.org/en/download/) version 12 or higher -- [Truffle](https://www.trufflesuite.com/truffle) +- [Hardhat](https://hardhat.org/hardhat-runner/docs/getting-started#overview) - [cURL command line](https://curl.haxx.se/download.html) - [MetaMask](https://metamask.io/) @@ -286,138 +286,96 @@ Besu doesn't incorporate [account management](../../public-networks/how-to/send- ## Smart contract and dapp usage -You can use a demo dapp called Pet Shop, provided by [Truffle](https://www.trufflesuite.com/tutorial). +You can use a demo dapp called QuorumToken which makes use of an ERC20 token that is deployed to the chain. -The dapp runs a local website using Docker, and uses smart contracts deployed on the network. +Behind the scenes uses [Hardhat](https://www.npmjs.com/package/hardhat), [Ethers](https://www.npmjs.com/package/ethers) and [MetaMask](https://metamask.io/) to interact with the chain. As such the process comprises two parts: -The directory created by `quorum-dev-quickstart` includes a `dapps` directory with a `pet-shop` subdirectory, which contains the source code for the dapp, including the smart contracts, website, and configurations to run this tutorial. +1. Deploy the contract to the chain and **save the contract's address** +2. Start the DApp and use the UI to read and transact on the chain with the token. -With the blockchain running and MetaMask connected to `Localhost 8545` via the browser, run the following command to start the Pet Shop dapp: +The `dapps/quorumToken` folder is this structured in this manner (only relevant paths shown): ```bash -cd dapps/pet-shop -./run_dapp.sh +quorumToken +├── hardhat.config.ts // hardhat network config +├── contracts // the QuorumToken.sol +├── scripts // handy scripts eg: to deploy to a chain +├── test // contract tests +└── frontend // DApp done in next.js + ├── public + ├── src + ├── styles + ├── tsconfig.json ``` -The script: - -1. Installs the dapp Node dependencies (you may see some warnings here, but it will not prevent the dapp from running). -1. Compiles the contracts. -1. Deploys the contracts to the blockchain. -1. Runs tests. -1. Builds and runs a Docker image to serve the dapp website. - -```text './run_dapp.sh' example output -Compiling your contracts... -=========================== -> Compiling ./contracts/Adoption.sol -> Compiling ./contracts/Migrations.sol -> Artifacts written to /Users/demo/quorum-test-network/dapps/pet-shop/pet-shop-box/build/contracts -> Compiled successfully using: - - solc: 0.5.16+commit.9c3226ce.Emscripten.clang - -Starting migrations... -====================== -> Network name: 'quickstartWallet' -> Network id: 1337 -> Block gas limit: 16234336 (0xf7b760) - -1_initial_migration.js -====================== - - Deploying 'Migrations' - ---------------------- - > transaction hash: 0xdd27f5bc5b0c4a42bb4f4d9ba00b4d33742de10ba8f03484cbf095ee824ba11a - > Blocks: 0 Seconds: 0 - > contract address: 0xFB88dE099e13c3ED21F80a7a1E49f8CAEcF10df6 - > block number: 2747 - > block timestamp: 1618000437 - > account: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57 - > balance: 89999.97435026 - > gas used: 221555 (0x36173) - > gas price: 20 gwei - > value sent: 0 ETH - > total cost: 0.0044311 ETH - - - > Saving migration to chain. - > Saving artifacts - ------------------------------------- - > Total cost: 0.0044311 ETH - -2_deploy_contracts.js -===================== - - Deploying 'Adoption' - -------------------- - > transaction hash: 0xd6f5b11807a0727a92b6063c95b9101769d310592b0d3cf35d6df233d05d50e6 - > Blocks: 0 Seconds: 0 - > contract address: 0xf204a4Ef082f5c04bB89F7D5E6568B796096735a - > block number: 2749 - > block timestamp: 1618000441 - > account: 0x627306090abaB3A6e1400e9345bC60c78a8BEf57 - > balance: 89999.968712 - > gas used: 239915 (0x3a92b) - > gas price: 20 gwei - > value sent: 0 ETH - > total cost: 0.0047983 ETH - - - > Saving migration to chain. - > Saving artifacts - ------------------------------------- - > Total cost: 0.0047983 ETH - -Summary -======= -> Total deployments: 2 -> Final cost: 0.0092294 ETH - - -Using network 'quickstartWallet'. - -Compiling your contracts... -=========================== -> Compiling ./test/TestAdoption.sol - -TestAdoption -✓ testUserCanAdoptPet (2071ms) -✓ testGetAdopterAddressByPetId (6070ms) -✓ testGetAdopterAddressByPetIdInArray (6077ms) - -3 passing (37s) +### Deploy the contract +Once the chain is up and running, enter the `quorumToken` folder and run the following: + +```bash +# install dependencies +npm i +# compile the contract +npm run compile +npm run test +# deploy the contract to the quickstart network +npm run deploy-quorumtoken ``` +with the output +```bash -After these tests are successful, the script builds a container for the Pet Shop dapp and deploys it, binding it to port 3001 on your system. +# compile +> quorumToken@1.0.0 compile +> npx hardhat compile -```text -Sending build context to Docker daemon 489.4MB -Step 1/5 : FROM node:12.14.1-stretch-slim ----> 2f7e25ad14ea -Step 2/5 : EXPOSE 3001 ----> Using cache ----> 2ef0665a040a -Step 3/5 : WORKDIR /app ----> Using cache ----> e8e97cedb575 -Step 4/5 : COPY . /app ----> f70e4265e598 -Step 5/5 : CMD npm run dev ----> Running in 3c6e8bdb3f3b -Removing intermediate container 3c6e8bdb3f3b ----> ce2588e47ab0 -Successfully built ce2588e47ab0 -Successfully tagged quorum-dev-quickstart_pet_shop:latest -b1615ab765656bc027f63fc60019dba1ca572305766c820f41eaf113b7e14cf8 +Generating typings for: 5 artifacts in dir: typechain-types for target: ethers-v6 +Successfully generated 24 typings! +Compiled 5 Solidity files successfully + +# test +> quorumToken@1.0.0 test +> npx hardhat test + + QuorumToken + Deployment + ✔ Should have the correct initial supply (1075ms) + ✔ Should token transfer with correct balance (78ms) + + + 2 passing (1s) + +# deploy +Contract deploy at: 0x5FbDB2315678afecb367f032d93F642f64180aa3 +``` +This will deploy the contract to the network and return the address. **Please save this address for the next step.** + +### Run the DApp + +The dapp runs a local website using next.js, and uses the contract in the previous step deployed on the network. + +With the blockchain running, and MetaMask connected to **Localhost 8545**, import one of [our test accounts via private key](../reference/accounts-for-testing.md). Then run the following command: + +```bash +cd frontend +npm i +npm run dev ``` +This starts the DApp, binding it to port 3001 on your system. -In the browser where you have MetaMask enabled and one of the test accounts loaded, open a new tab and navigate to [the Pet Shop dapp](http://localhost:3001) where you can adopt lovely pets (sorry, not for real, it's a demo). +```text -When you select **Adopt**, a MetaMask window pops up and requests your permission to continue with the transaction. +> webapp@0.1.0 dev +> next dev -p 3001 -After the transaction is complete and successful, the status of the pet you adopted shows **Success**. +- ready started server on [::]:3001, url: http://localhost:3001 +- event compiled client and server successfully in 270 ms (18 modules) +- wait compiling... +- event compiled client and server successfully in 173 ms (18 modules) +``` -![Dapp UI](../../assets/images/dapp-ui.png) +In the browser where you have MetaMask enabled and one of the test accounts loaded, open a new tab and navigate to [the QuorumToken dapp](http://localhost:3001). +Connect to MetaMask and input the address from the previous step. Fox example our contract above deployed to `0x5FbDB2315678afecb367f032d93F642f64180aa3`. + +The DApp will then read the balance of the account from MetaMask and get details of the contract. You can then send funds to another address (any of the other test accounts) on the network and MetaMask will sign and send the transaction. You can also search for the transaction and view its details in the [Block Explorer](http://localhost:25000/). @@ -429,42 +387,39 @@ The MetMask UI also keeps a record of the transaction. ### Deploy your own dapp -You can deploy your own dapp to the Quorum Developer Quickstart, by configuring your dapp to point to the Quickstart network. +You can deploy your own dapp to the Quorum Developer Quickstart by configuring your dapp to point to the Quickstart network. -If you're using [Truffle](https://trufflesuite.com/truffle/), update the `networks` object in the [Truffle configuration file](https://trufflesuite.com/docs/truffle/reference/configuration#networks) to specify which networks to connect to for deployments and testing. The Quickstart RPC service endpoint is `http://localhost:8545`. +We recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/project-setup), and you can use the sample `hardhat.config.js` to configure the networks object in the [Hardhat configuration file](https://hardhat.org/hardhat-network/docs/reference#config) to specify which networks to connect to for deployments and testing. The Quickstart's RPC service endpoint is `http://localhost:8545`. -For example, the following is the Truffle configuration file for the Pet Shop dapp used in the Quickstart Besu network: +For example, the following is the Hardhat configuration file for the QuorumToken dapp used in the Quickstart GoQuorum network: ```js -const PrivateKeyProvider = require("@truffle/hdwallet-provider"); - -// insert the private key of the account used in MetaMask, e.g. Account 1 (Miner Coinbase Account) -const privateKey = - "c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"; - module.exports = { networks: { - development: { - host: "127.0.0.1", - port: 7545, - network_id: "*", // Match any network id - }, - develop: { - port: 8545, - }, - quickstartWallet: { - provider: () => - new PrivateKeyProvider(privateKey, "http://localhost:8545"), - network_id: "*", + // in built test network to use when developing contracts + hardhat: { + chainId: 1337 }, - }, -}; + quickstart: { + url: "http://127.0.0.1:8545", + chainId: 1337, + // test accounts only, all good ;) + accounts: [ + "0x8f2a55949038a9610f50fb23b5883af3b4ecb3c3bb792cbcefbd1542c692be63", + "0xc87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3", + "0xae6ae8e5ccbfb04590405997ee2d52d2b330726137b875053c36d94e974d162f" + ] + } + }, + defaultNetwork: "hardhat", + ... + ... ``` -Deploy the dapp using: +Deploy the contract using: ```bash -truffle migrate --network quickstartWallet +npx hardhat run ./scripts/deploy_quorumtoken.ts --network quickstart ``` ## Stop and restart the private network without removing containers diff --git a/docs/public-networks/how-to/develop/hardhat.md b/docs/public-networks/how-to/develop/hardhat.md new file mode 100644 index 00000000000..23a0d8f0abb --- /dev/null +++ b/docs/public-networks/how-to/develop/hardhat.md @@ -0,0 +1,64 @@ +--- +title: Use Hardhat +sidebar_position: 1 +description: Using Hyperledger Besu with Hardhat +tags: + - public networks + - private networks +--- + +# Use Hardhat + +Developing for Hyperledger Besu using Hardhat is the same as developing for public Ethereum networks using Hardhat. Hardhat supports Besu with the only difference being Besu does not support private key management. To use Besu with Hardhat, you must configure a wallet. + +## Use a HD wallet + +To add the wallet provider, update the `hardhat.config.ts` file in the project directory. Replace: + +- `` with the JSON-RPC endpoint (IP address and port) of a Besu node. +- `` with the list of words that make up your account's mnemonic. +- ` your password if used +- `` your account's private key + +```js +module.exports = { + // See + // for more about customizing your Hardhat configuration! + networks: { + besuWallet: { + url: "", + accounts: { + mnemonic: "", + path: "m/44'/60'/0'/0", + initialIndex: 0, + count: 1, + passphrase: "", + }, + }, + }, +}; +``` + +## Alternatively, via a private key in code + +Please make sure you do not commit and private keys to source control like Github, always inject your keys at runtime as env vars, or use the likes of a vault. + +```js +const provider = new ethers.JsonRpcApiProvider(); +const wallet = new ethers.Wallet(); +// connect the wallet to the provider +const signer = wallet.connect(provider); + +``` + +## Start a Besu node + +Start a Besu node with JSON-RPC enabled on the endpoint specified in the Hardhat configuration file. + +## Deploy a contract + +To deploy a contract onto the Besu network: + +```bash +npx hardhat scripts run ./scripts/deploy_my_contract.ts --network besuWallet +``` diff --git a/docs/public-networks/how-to/develop/truffle.md b/docs/public-networks/how-to/develop/truffle.md deleted file mode 100644 index a97d5d4620a..00000000000 --- a/docs/public-networks/how-to/develop/truffle.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -title: Use Truffle -sidebar_position: 1 -description: Using Hyperledger Besu with Truffle -tags: - - public networks - - private networks ---- - -# Use Truffle - -Developing for Hyperledger Besu using Truffle is the same as developing for public Ethereum networks using Truffle. Truffle supports Besu with the only difference being Besu does not support private key management. To use Besu with Truffle, you must configure a Truffle wallet. - -## Install a Truffle wallet - -To install a Truffle wallet: - -```bash -npm install --save @truffle/hdwallet-provider -``` - -:::note - -With Truffle 5, you must use a Web3 1.0 enabled wallet or the Truffle tasks hang. - -::: - -### Update the Truffle configuration file - -To add the wallet provider, update the `truffle-config.js` file in the project directory. Replace: - -- `` with the JSON-RPC endpoint (IP address and port) of a Besu node. -- `` with the private key of an Ethereum account containing Ether. - -```javascript -const PrivateKeyProvider = require("@truffle/hdwallet-provider"); -const privateKey = ""; -const privateKeyProvider = new PrivateKeyProvider( - privateKey, - "", -); - -module.exports = { - // See - // for more about customizing your Truffle configuration! - networks: { - besuWallet: { - provider: privateKeyProvider, - network_id: "*", - }, - }, -}; -``` - -### Start a Besu node - -Start a Besu node with JSON-RPC enabled on the endpoint specified in the Truffle configuration file. - -### Deploy a contract - -To deploy a contract onto the Besu network: - -```bash -truffle migrate --network besuWallet -``` From 157f41763ca4e88056f9528e197efabc67a2c14b Mon Sep 17 00:00:00 2001 From: bgravenorst Date: Mon, 28 Aug 2023 14:02:04 +1000 Subject: [PATCH 2/5] Minor edits. Signed-off-by: bgravenorst --- docs/private-networks/tutorials/quickstart.md | 36 +++++++++++-------- .../public-networks/how-to/develop/hardhat.md | 18 +++++++--- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/docs/private-networks/tutorials/quickstart.md b/docs/private-networks/tutorials/quickstart.md index 348fac5fa2d..c88355a4f24 100644 --- a/docs/private-networks/tutorials/quickstart.md +++ b/docs/private-networks/tutorials/quickstart.md @@ -286,12 +286,12 @@ Besu doesn't incorporate [account management](../../public-networks/how-to/send- ## Smart contract and dapp usage -You can use a demo dapp called QuorumToken which makes use of an ERC20 token that is deployed to the chain. +You can use a demo dapp called QuorumToken which uses an ERC20 token that is deployed to the network. -Behind the scenes uses [Hardhat](https://www.npmjs.com/package/hardhat), [Ethers](https://www.npmjs.com/package/ethers) and [MetaMask](https://metamask.io/) to interact with the chain. As such the process comprises two parts: +We'll use [Hardhat](https://www.npmjs.com/package/hardhat), [Ethers](https://www.npmjs.com/package/ethers) and [MetaMask](https://metamask.io/) to interact with the network, which involves the following steps: -1. Deploy the contract to the chain and **save the contract's address** -2. Start the DApp and use the UI to read and transact on the chain with the token. +1. Deploy the contract and **save the contract's address**. +1. Start the dapp, and read and transact with the deployed token. The `dapps/quorumToken` folder is this structured in this manner (only relevant paths shown): @@ -301,7 +301,7 @@ quorumToken ├── contracts // the QuorumToken.sol ├── scripts // handy scripts eg: to deploy to a chain ├── test // contract tests -└── frontend // DApp done in next.js +└── frontend // dapp done in next.js ├── public ├── src ├── styles @@ -309,7 +309,8 @@ quorumToken ``` ### Deploy the contract -Once the chain is up and running, enter the `quorumToken` folder and run the following: + +Once the network is up and running, enter the `quorumToken` directory and run the following: ```bash # install dependencies @@ -320,7 +321,8 @@ npm run test # deploy the contract to the quickstart network npm run deploy-quorumtoken ``` -with the output +The output is similar to the following: + ```bash # compile @@ -346,20 +348,20 @@ Compiled 5 Solidity files successfully # deploy Contract deploy at: 0x5FbDB2315678afecb367f032d93F642f64180aa3 ``` -This will deploy the contract to the network and return the address. **Please save this address for the next step.** +This will deploy the contract to the network and return the address. **Please save this address for the next step**. -### Run the DApp +### Run the dapp -The dapp runs a local website using next.js, and uses the contract in the previous step deployed on the network. +The dapp runs a local website using Next.js, and uses the contract in the previous step deployed on the network. -With the blockchain running, and MetaMask connected to **Localhost 8545**, import one of [our test accounts via private key](../reference/accounts-for-testing.md). Then run the following command: +With the blockchain running, and MetaMask connected to `localhost` on port `8545`, import one of [our test accounts via private key](../reference/accounts-for-testing.md), and run the following command: ```bash cd frontend npm i npm run dev ``` -This starts the DApp, binding it to port 3001 on your system. +This starts the dapp, binding it to port `3001` on your machine. ```text @@ -372,10 +374,12 @@ This starts the DApp, binding it to port 3001 on your system. - event compiled client and server successfully in 173 ms (18 modules) ``` -In the browser where you have MetaMask enabled and one of the test accounts loaded, open a new tab and navigate to [the QuorumToken dapp](http://localhost:3001). +In the browser where you have MetaMask enabled and one of the test accounts loaded, open a new tab and navigate to +[the QuorumToken dapp](http://localhost:3001). Connect to MetaMask and input the address from the previous step. Fox example our contract above deployed to `0x5FbDB2315678afecb367f032d93F642f64180aa3`. -The DApp will then read the balance of the account from MetaMask and get details of the contract. You can then send funds to another address (any of the other test accounts) on the network and MetaMask will sign and send the transaction. +The dapp will then read the balance of the account from MetaMask and get details of the contract. You can then send funds +to another address (any of the other test accounts) on the network, and MetaMask will sign and send the transaction. You can also search for the transaction and view its details in the [Block Explorer](http://localhost:25000/). @@ -389,7 +393,9 @@ The MetMask UI also keeps a record of the transaction. You can deploy your own dapp to the Quorum Developer Quickstart by configuring your dapp to point to the Quickstart network. -We recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/project-setup), and you can use the sample `hardhat.config.js` to configure the networks object in the [Hardhat configuration file](https://hardhat.org/hardhat-network/docs/reference#config) to specify which networks to connect to for deployments and testing. The Quickstart's RPC service endpoint is `http://localhost:8545`. +We recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/project-setup), and you can use the sample +`hardhat.config.js` to configure the `networks` object in the [Hardhat configuration file](https://hardhat.org/hardhat-network/docs/reference#config) +to specify which networks to connect to for deployments and testing. The Quickstart's RPC service endpoint is `http://localhost:8545`. For example, the following is the Hardhat configuration file for the QuorumToken dapp used in the Quickstart GoQuorum network: diff --git a/docs/public-networks/how-to/develop/hardhat.md b/docs/public-networks/how-to/develop/hardhat.md index 23a0d8f0abb..06b4a800171 100644 --- a/docs/public-networks/how-to/develop/hardhat.md +++ b/docs/public-networks/how-to/develop/hardhat.md @@ -9,9 +9,14 @@ tags: # Use Hardhat -Developing for Hyperledger Besu using Hardhat is the same as developing for public Ethereum networks using Hardhat. Hardhat supports Besu with the only difference being Besu does not support private key management. To use Besu with Hardhat, you must configure a wallet. +Developing for Hyperledger Besu using Hardhat is the same as developing for public Ethereum networks using Hardhat. Hardhat +supports Besu with the only difference being Besu does not support private key management. -## Use a HD wallet +You can therefore use a wallet provider, or specify your private key in the code. + +## Private key management + +### Use an HD wallet To add the wallet provider, update the `hardhat.config.ts` file in the project directory. Replace: @@ -39,9 +44,14 @@ module.exports = { }; ``` -## Alternatively, via a private key in code +### Specify your private key in code + +:::danger + +Ensure you do not commit private keys to source control like Github, always inject your keys at runtime as environment variables, or +use a vault or similar. -Please make sure you do not commit and private keys to source control like Github, always inject your keys at runtime as env vars, or use the likes of a vault. +::: ```js const provider = new ethers.JsonRpcApiProvider(); From f4b247dbfefba67edaa3ab112960049583f656d4 Mon Sep 17 00:00:00 2001 From: Joshua Fernandes Date: Mon, 28 Aug 2023 14:56:31 +1000 Subject: [PATCH 3/5] adding warning to smart-contracts page Signed-off-by: Joshua Fernandes --- .../tutorials/permissioning/onchain.md | 12 ++++++++++++ .../tutorials/permissioning/upgrade-contracts.md | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docs/private-networks/tutorials/permissioning/onchain.md b/docs/private-networks/tutorials/permissioning/onchain.md index e9d2353a0cd..b34e0dd1bd1 100644 --- a/docs/private-networks/tutorials/permissioning/onchain.md +++ b/docs/private-networks/tutorials/permissioning/onchain.md @@ -12,6 +12,18 @@ The following steps describe bootstrapping a permissioned network using a Hyperl This tutorial configures permissioning on a [IBFT 2.0 proof of authority (PoA)] network. +:::warning Security warning + +**Please use this as reference material only!** + +The [permissioning-contract-repo](https://github.com/ConsenSys/permissioning-smart-contracts) has been archived and is intended as reference material only. +Please update all dependencies in there before proceeding. + +In addition we also recommend you using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), +as the development environment. Please refer to the Quorum Dev Quickstart for an [example](../../tutorials/quickstart.md) + +::: + ## Prerequisites - [Node.js](https://nodejs.org/en/) v10.16.0 or later diff --git a/docs/private-networks/tutorials/permissioning/upgrade-contracts.md b/docs/private-networks/tutorials/permissioning/upgrade-contracts.md index 00078d551b2..5186718199f 100644 --- a/docs/private-networks/tutorials/permissioning/upgrade-contracts.md +++ b/docs/private-networks/tutorials/permissioning/upgrade-contracts.md @@ -10,6 +10,18 @@ tags: The following tutorial describes the steps to upgrade the onchain permissioning contracts to the latest version. +:::warning Security warning + +**Please use this as reference material only!** + +The [permissioning-contract-repo](https://github.com/ConsenSys/permissioning-smart-contracts) has been archived and is intended as reference material only. +Please update all dependencies in there before proceeding. + +In addition we also recommend you using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), +as the development environment. Please refer to the Quorum Dev Quickstart for an [example](../../tutorials/quickstart.md) + +::: + ## Prerequisites @@ -19,8 +31,10 @@ The following tutorial describes the steps to upgrade the onchain permissioning - [Yarn](https://yarnpkg.com/en/) v1.15 or later - Browser with [MetaMask installed](https://metamask.io/). + ## Steps + ### 1. Get the latest contracts and install dependencies :::note From a39b5b8b3b035bc9499f8fce543a1a9eb5f69c82 Mon Sep 17 00:00:00 2001 From: bgravenorst Date: Mon, 28 Aug 2023 17:15:51 +1000 Subject: [PATCH 4/5] Minor edits. Signed-off-by: bgravenorst --- docs/private-networks/tutorials/permissioning/onchain.md | 6 ++---- .../tutorials/permissioning/upgrade-contracts.md | 6 ++---- docs/private-networks/tutorials/quickstart.md | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/docs/private-networks/tutorials/permissioning/onchain.md b/docs/private-networks/tutorials/permissioning/onchain.md index b34e0dd1bd1..e9b667d3731 100644 --- a/docs/private-networks/tutorials/permissioning/onchain.md +++ b/docs/private-networks/tutorials/permissioning/onchain.md @@ -12,14 +12,12 @@ The following steps describe bootstrapping a permissioned network using a Hyperl This tutorial configures permissioning on a [IBFT 2.0 proof of authority (PoA)] network. -:::warning Security warning - -**Please use this as reference material only!** +:::caution Please use this as reference material only! The [permissioning-contract-repo](https://github.com/ConsenSys/permissioning-smart-contracts) has been archived and is intended as reference material only. Please update all dependencies in there before proceeding. -In addition we also recommend you using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), +In addition, we also recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), as the development environment. Please refer to the Quorum Dev Quickstart for an [example](../../tutorials/quickstart.md) ::: diff --git a/docs/private-networks/tutorials/permissioning/upgrade-contracts.md b/docs/private-networks/tutorials/permissioning/upgrade-contracts.md index 5186718199f..5130fbb8c36 100644 --- a/docs/private-networks/tutorials/permissioning/upgrade-contracts.md +++ b/docs/private-networks/tutorials/permissioning/upgrade-contracts.md @@ -10,14 +10,12 @@ tags: The following tutorial describes the steps to upgrade the onchain permissioning contracts to the latest version. -:::warning Security warning - -**Please use this as reference material only!** +:::caution Please use this as reference material only! The [permissioning-contract-repo](https://github.com/ConsenSys/permissioning-smart-contracts) has been archived and is intended as reference material only. Please update all dependencies in there before proceeding. -In addition we also recommend you using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), +In addition we also recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), as the development environment. Please refer to the Quorum Dev Quickstart for an [example](../../tutorials/quickstart.md) ::: diff --git a/docs/private-networks/tutorials/quickstart.md b/docs/private-networks/tutorials/quickstart.md index c88355a4f24..e5c1dbbbf01 100644 --- a/docs/private-networks/tutorials/quickstart.md +++ b/docs/private-networks/tutorials/quickstart.md @@ -293,7 +293,7 @@ We'll use [Hardhat](https://www.npmjs.com/package/hardhat), [Ethers](https://www 1. Deploy the contract and **save the contract's address**. 1. Start the dapp, and read and transact with the deployed token. -The `dapps/quorumToken` folder is this structured in this manner (only relevant paths shown): +The `dapps/quorumToken` directory is this structured in this manner (only relevant paths shown): ```bash quorumToken From 9f6e81e96eff0db629be4c6c226317420d8b54e6 Mon Sep 17 00:00:00 2001 From: bgravenorst Date: Mon, 28 Aug 2023 17:22:51 +1000 Subject: [PATCH 5/5] Fix admonition. Signed-off-by: bgravenorst --- docs/private-networks/tutorials/permissioning/onchain.md | 2 +- .../tutorials/permissioning/upgrade-contracts.md | 2 +- docs/private-networks/tutorials/quickstart.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/private-networks/tutorials/permissioning/onchain.md b/docs/private-networks/tutorials/permissioning/onchain.md index e9b667d3731..2d2655b0b3c 100644 --- a/docs/private-networks/tutorials/permissioning/onchain.md +++ b/docs/private-networks/tutorials/permissioning/onchain.md @@ -18,7 +18,7 @@ The [permissioning-contract-repo](https://github.com/ConsenSys/permissioning-sma Please update all dependencies in there before proceeding. In addition, we also recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), -as the development environment. Please refer to the Quorum Dev Quickstart for an [example](../../tutorials/quickstart.md) +as the development environment. Please refer to the [Quorum Dev Quickstart](../../tutorials/quickstart.md) for an example. ::: diff --git a/docs/private-networks/tutorials/permissioning/upgrade-contracts.md b/docs/private-networks/tutorials/permissioning/upgrade-contracts.md index 5130fbb8c36..7d44a43b56a 100644 --- a/docs/private-networks/tutorials/permissioning/upgrade-contracts.md +++ b/docs/private-networks/tutorials/permissioning/upgrade-contracts.md @@ -16,7 +16,7 @@ The [permissioning-contract-repo](https://github.com/ConsenSys/permissioning-sma Please update all dependencies in there before proceeding. In addition we also recommend using [Hardhat](https://hardhat.org/hardhat-runner/docs/guides/deploying) instead of [Truffle](https://trufflesuite.com/), -as the development environment. Please refer to the Quorum Dev Quickstart for an [example](../../tutorials/quickstart.md) +as the development environment. Please refer to the [Quorum Dev Quickstart](../../tutorials/quickstart.md) for an example. ::: diff --git a/docs/private-networks/tutorials/quickstart.md b/docs/private-networks/tutorials/quickstart.md index e5c1dbbbf01..abff0a9ab90 100644 --- a/docs/private-networks/tutorials/quickstart.md +++ b/docs/private-networks/tutorials/quickstart.md @@ -14,7 +14,7 @@ import Postman from '../../global/postman.md'; The Quorum Developer Quickstart uses the Hyperledger Besu Docker image to run a private [IBFT 2.0](../how-to/configure/consensus/ibft.md) network of Besu nodes managed by Docker Compose. -:::danger +:::caution This tutorial runs a private network suitable for education or demonstration purposes and is not intended for running production networks.