-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joshua Fernandes <joshua.fernandes@consensys.net>
- Loading branch information
1 parent
2654332
commit 8ab1957
Showing
6 changed files
with
181 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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: | ||
|
||
- `<JSON-RPC-http-endpoint>` with the JSON-RPC endpoint (IP address and port) of a Besu node. | ||
- `<MY-ACCOUNT-MNEUMONIC>` with the list of words that make up your account's mneumonic. | ||
- `<MY-PASSWORD`> your password if used | ||
- `<MY-ACCOUNT-PRIVATE-KEY>` your account's private key | ||
|
||
```js | ||
module.exports = { | ||
// See <https://hardhat.org/hardhat-runner/docs/config#hd-wallet-config> | ||
// for more about customizing your Hardhat configuration! | ||
networks: { | ||
besuWallet: { | ||
url: "<JSON-RPC-http-endpoint>", | ||
accounts: { | ||
mnemonic: "<ACCOUNT-MNEUMONIC>", | ||
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(<JSON-RPC-http-endpoint>); | ||
const wallet = new ethers.Wallet(<MY-ACCOUNT-PRIVATE-KEY>); | ||
// 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 | ||
``` |
Oops, something went wrong.