- Users register with information such as username, password, name and wallet address .
- Information is stored in the database .
- User login as usually and backend migrate a new contract and send contract address to user
- User sends a transaction (does not send ETH, only calls the contract function and pays the gas fee) to the 2FA contract.
- Backend check that contract have authenticated or not
- User is authenticated.
Dependencies:
- Node v7.6+ (NodeJs)
- ReactJs
- Truffle
- Rinkeby network
- Metamask
Create .env file
MNEMONIC = 'YOUR MNEMONIC',
INFURA_KEY = <YOUR INFURA KEY>
Create .enc in /backend
MONGODB_URI = 'LINK TO MONGODB', //like : MONGODB_URI = 'mongodb://dohoang123:[email protected]:47467/2fa-ethereum',
MNEMONIC = <YOUR MNEMONIC>
INFURA_KEY = <YOUR INFURA KEY>
In ./ and ./backend and ./frontend
npm install
or
yarn install
set up HDWalletProvider in contractWithBlockchain.js to any network you want
let provider = new HDWalletProvider(
process.env.MNEMONIC,
`https://rinkeby.infura.io/v3/${process.env.INFURA_KEY}`
);
and then
yarn truffle develop --network truffleTestnet
Then run the console
yarn truffle console --network truffleTestnet
Run script in truffle develop
// send 1 eth
web3.eth.sendTransaction({
from: accounts[0],
to: 'YOUR ACCOUNT ADDRESS',
value: web3.utils.toWei('1', 'ether')
});
After fauct eth from account(0) , now you have enough eth to deploy
yarn truffle migrate --reset --network truffleTestnet
yarn truffle migrate --network rinkeby
cd backend/
yarn
yarn start
cd frontend/
yarn
yarn start
# In a new terminal window, run the truffle tests
truffle test