BookDatabase is a smart contract written in Solidity for use on the Ethereum blockchain. It allows the storage, modification, and deletion of book records in a decentralized manner. The contract is immutable once deployed, with an owner-centric permission system for modifying book records. Here is the contract deployed in a sepolia testnet: https://sepolia.etherscan.io/address/0xb4bdab41d1e0abf9eff2564a29f316443ec80b16#code;
- Add new book records with title and year.
- Edit existing book records.
- Remove book records.
- Count the total number of books in the database.
- Restrict access to book modification to the contract owner.
To set up the BookDatabase project locally, follow these steps:
- Clone the repository to your local machine.
- Install dependencies with
yarn install
. - Set up a
.env
file with your custom network URLs and mnemonics.
The project can be interacted with using scripts provided in the package.json
file:
yarn compile
: Compiles the smart contract.yarn test
: Runs tests using Hardhat's coverage plugin.yarn start
: Starts a local Hardhat node.yarn deploy:sepolia
: Deploys the contract to the Sepolia testnet.yarn deploy:dev
: Deploys the contract to a local network.
addBook(Book memory book)
: Adds a new book to the database.editBook(uint32 id, Book memory book)
: Edits an existing book.removeBook(uint32 id)
: Removes a book from the database.count()
: Returns the number of books in the database.
- Node.js
- Yarn
- An Ethereum wallet with a mnemonic for deploying the contract
The hardhat.config.ts
file contains network configuration for local and Sepolia networks. Make sure to provide the correct environment variables for SEPOLIA_URL
, SEPOLIA_MNEMONIC
, and ETHERSCAN_API_KEY
.
Contributions are welcome! Please open an issue or submit a pull request for any bugs, features, or improvements.
This project is open-sourced software licensed under the MIT license.