This template allows a user to (a) utilise a smart contract template that can be deployed on Ethereum's blockchain, (b) connect the smart contract to a local repository, (c) interact with the smart contract through a frontend, and (d) customize frontend whilst still being connected to the smart contract.
- (a):
Secret.sol
: Smart contract written in Solidity with two simple functions - (b):
app.js
: Interacting with the smart contract on Ethereum's blockchain - change two variables to add your own contract once you have deployed it. - (c):
app.js
andindex.html
: Intuitive and simple interaction between the html (frontend) and JavaScript (using web3.js to interact with the smart contract) - (d):
index.css
: Simple CSS to customize the website
- Clone Repository
- cd To Repository
- Run
npm install
- Run local server:
npm run dev
- Edit changes to the template in a code editor. Changes are automatically shown on localhost.
This repository is connected to a deployed contract on Ropsten Test Network. The smart contract in this repository [Secret.sol] is simply included as a smart contract template. To add your own contract:
- Use the smart contract in this repository as your template
- Go to Remix IDE (https://remix.ethereum.org/) and try interacting with the template to check that everything works
- Deploy the contract
- Go to [app.js] and change the
ABI
andvar contractAddress
Our template contract is written in Solidity and has two main funcitons:
setSecretWord
allows the user to set "a secret word"getSecretWord
: retrieving the latest "secret word"
The file is included in this repo for reference, but not used for other purposes. The exact same smart contract is deployed on Ropsten - hence, changes in this file will not affect the template.
- You need MetaMask for this template - it is injecting the web3
- If you are using the pre-made template, remember switching to "Ropsten Test Network" on MetaMask
- Don't have Ether on your Ropsten Account? Use Faucet (https://faucet.metamask.io/)