Skip to content

This is a simple but test-complete example implementation of an Ethereum smart contract, using Hardhat, OpenZeppelin's Contract Library, Waffle, and Chai

Notifications You must be signed in to change notification settings

xtyrrell/ethereum-box

Repository files navigation

Ethereum Box

This is a simple but test-complete example of an end-to-end Etherum dApp implementation.

There is a smart contract contracts/Box.sol written in Solidity 0.7.3, which simply holds two values: publicValue, which anyone can read and anyone can write, and restrictedValue, which anyone can read but only the contract owner can write.

There is a test suite against this smart contract in test/Box.js.

Finally, there is a HTML, SASS and vanilla JS frontend with MetaMask integration that allows users to read and write to the two values.

It's a simple but comprehensive example of everything you'll need to build a small dApp on the Ethereum blockchain.

The Box smart contract comes from excellent OpenZeppelin's Developing Smart Contracts guide.

Get building

Prerequisites

  • You'll need a recent version of node installed (if you haven't got it installed, try installing it through the excellent asdf version manager).

Setup instructions

  1. Clone and enter the project and install dependencies.
git clone https://github.com/xtyrrell/ethereum-box.git
cd ethereum-box
npm i
  1. (In a different terminal) Start a Hardhat Network node to run a development-friendly version of the Ethereum blockhain locally.
npx hardhat node
  1. Run the tests to get an idea of the smart contract's expected functionality and see that everything works.
npx hardhat test
  1. Hack on Box.sol or create more contracts!

  2. Deploy the contract and set the deployed address in the frontend.

npx hardhat run --network localhost scripts/deploy.js
# Box deployed to 0x5FbDB2315678afecb367f032d93F642f64180aa3

Set CONTRACT_ADDRESS at the top of src/script.js to the address just printed.

  1. Start the frontend.
npm start

About

This is a simple but test-complete example implementation of an Ethereum smart contract, using Hardhat, OpenZeppelin's Contract Library, Waffle, and Chai

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published