This is a sample project that demonstrates how to use Hardhat, an Ethereum development environment, to build and test smart contracts. The project includes smart contract for managing a hotel booking system on the Ethereum blockchain. It allows the hotel owner to add room details, check room availability, and book and checkout rooms.
To get started, you'll need to install Hardhat and its dependencies:
npm install --save-dev hardhat
npm install --save-dev @nomiclabs/hardhat-waffle
To compile the smart contracts:
npx hardhat compile
To run the tests:
npx hardhat test
To deploy the smart contracts to the Goerli testnet, you'll need to add the Goerli network to the hardhat.config.js file. Here are the steps to do that:
- Open the hardhat.config.js file in your text editor.
- Find the networks object and add the following code:
const privateKey = "PRIVATE-KEY"
module.exports = {
solidity: "0.8.18",
defaultNetwork: "goerli",
networks:{
goerli:{
url: 'NODE-URL',
accounts:[privateKey]
}
}
};
- Save the hardhat.config.js file. To deploy the smart contracts to the Goerli network, run the following command:
npx hardhat run --network goerli scripts/deploy.js