Simple Conference application where an conference owner can create a conference. Features are:
- Set ticket price of conference in ether. Could be [DAI](https://en.wikipedia.org/wiki/Dai_(cryptocurrency), USDC or any other token. E.g an ERC20-token.
- Set reward factor which is used to decide how much speakers will recieve as reward.
- Auth actors before they can be attendees or speakers
- This is done like this here, but we don't want the conference owner to pre-auth the actors. Should be done otherwise e.g. third-party authorization which then call the
auth
function
- Delegate auth priviligess to auth provider
- Give tickets to attendees
- Close registration which enables reward claims for conference owner and speakers
- Claim reward as conference owner/speaker
This repo is created to illustrate role logic in smart contracts and demonstrate development and testing of smart contract and how to interact with them from js/ts.
This process will let you run the frontend(dApp) with a local blockchain that runs the Conference contract. This let you use and develop you dApp locally. Hot-reload is enabled for both the contracts and frontend-code. You will need to download the Metamask to use the dApp with ethereum accounts(signing transactions).
- Clone the repo and cd into it
git clone https://github.com/symfoni/conference MyConference && cd MyConference
- Install deps with yarn
yarn
or npmnpm install
- Run tests by
npx hardhat test
- Start hardhat
npx hardhat node --watch
It runs up a Hardhat node, compile contracts, generates typescript interfaces, creates React context and instantiates your contract instances and factories with frontend provider.
- Open up a new terminal
- Enter the frontend directory:
cd frontend
- Install dependencies:
npm install
and start react app withnpm start
- Open your browser and install Metamask. IMPORTANT! Do this in a seperate profile in your browser to prevent using your real Metamask wallet
- Open Metamask extension
- Click
Get started
- Click
Import wallet
by theNo, I already have a Secret Recovery Phrase
option. ClickI agree
. - In the "Secret Recovery Phrase, use
test test test test test test test test test test test junk
. This is the same phrase used for deployment of the smart contract on your local hardhat node network. - Set a password(not important to be secure because this is just for testing on a test network)
- Click "All done"
- You will now see your Metamask account
- Click on your account avatar in top right corner.
- Click on "Settings"
- Go to "Advanced"
- Enable "Show test networks"
- Close Settings
- Change network in Metmask extension to local network at
http://localhost:8545
. This is the network you have running locally withhardhat
from Get Started
- Ensure Metamask RPC is set to
http://localhost:8545
and chainID31337
.
The frontend should open at http://localhost:3000/
Because of this default hardhat.config.ts it will first try to connect with an injected provider like Metamask (web3modal package does this).
If nothing found it will try to connect with your hardhat node. On localhost and hardhat nodes it will inject your mnemonic into the frontend so you have a "browser wallet" that can both call and send transactions. NB! Dont ever put a mnemonic with actual value here.
In hardhat.config.ts there is example on how to instruct your hardhat-network to use mnemonic or privatekey.
const config: HardhatUserConfig = {
react: {
providerPriority: ["web3modal", "hardhat"],
},
};
Ensure you are useing RPC to http://localhost:8545.
You may also need to set the chainID to 31337 if you are useing Hardhat blockchain development node.
eth_sendRawTransaction
Invalid nonce. Expected X but got X.
Reset your account in Metamask.