This is a Smart Contract Inbox project built using Ethereum smart contracts and web3.js. The project allows you to send and receive messages via a simple Ethereum smart contract. It also incorporates Ganache for local testing and Infura Ethereum Sepolia Faucet as a testnet for remote testing.
Before you begin, ensure you have met the following requirements:
- Node.js and npm installed
- Ganache installed
- Metamask extension installed in your browser
- An Infura account for Ethereum testnet access
- An Ethereum wallet (e.g., MetaMask) for transaction signing
To install and set up this project, follow these steps:
-
Clone the repository to your local machine:
git clone https://github.com/Sakaow/smartcontract-message.git
-
Change to the project directory:
cd inbox
-
Install project dependencies:
npm install
To configure the project, follow these steps:
-
Create a
.env
file in the project root directory to store your secret values. You can use the provided.env.example
as a template.cp .env.example .env
-
Open the
.env
file and fill in the following values:MNEMONIC
: Your 12-word mnemonic phrase for your Ethereum wallet.INFURA_API_KEY
: Your Infura API key for connecting to the Ethereum network.
To use the Smart Contract Inbox, you can perform the following actions:
-
Compile and deploy the smart contract to the local Ganache network:
npm run deploy-local
-
Deploy the smart contract to the Ropsten testnet (using Infura):
npm run deploy-ropsten
-
Interact with the deployed contract by sending and receiving messages:
npm run send-message "Your message here" npm run get-message
-
Explore the
inbox.js
script to see how to interact with the smart contract.
This project uses Mocha for testing. To run the tests, execute the following command:
npm test
Make sure you have Ganache running locally or are connected to the Ethereum testnet via Infura when running the tests.