A simple web app that permanently records a 140 character message into the Aion Network blockchain. View a running demo at https://aion-for-the-record.herokuapp.com/.
View the full tutorial here: https://medium.com/nodesmith-blog/for-the-record-a-web-app-starter-kit-built-on-aion-6dee39e1597b
This sample isn't a 'pure' dApp, because it utilizes a lightweight server component to handle writing transactions to the Aion network. However, this is a very useful pattern when you wish to pay the transaction fees for your users. This repository will soon have a sister repo that utilizes the Aiwa Wallet to provide a client only experience.
- an API Key from Nodesmith
- node.js version 10 or higher installed
- installed Aion Desktop Wallet
Run npm install
.
First, you will need to extract the keystore for an account to a known location. Here are instructions for doing this from the Aion Desktop Wallet.
Make note of the location of the exported keystore and the password that you chose to protect the keystore.
Next, run the following script npm run generateKey -- PATH_TO_KEYSTORE KEYSTORE_PASSWORD
with PATH_TO_KEYSTORE
and KEYSTORE_PASSWORD
replaced with the correct values. For example: npm run generateKey -- ./contract/demoKeyStore 123
. This script will generate a private key based on your keystore. Keep this private key safe, and never store it client side.
Finally, replace FTR_PRIVATE_KEY
in ./contract/constants.js
with this value. Alternatively, you can set the FTR_PRIVATE_KEY environment variable.
Replace NODESMITH_API_KEY
in ./contract/constants.js
with your API Key. Alternatively, you can set the NODESMITH_API_KEY environment variable.
The Nodesmith endpoint is currently configured to use the Mastery testnet. When you are ready to deploy your contract
on the mainnet, you can edit the NODESMITH_ENDPOINT
in that file to point to the mainnet.
In order to deploy a contract and send transaction, your account will need some Aion coin.
You can request some testnet Aion from the Mastery Faucet.
The main contract can be found in ./contract/ForTheRecord.sol
.
- Run
npm run deploy
to compile & deploy the contract. - Replace
FTR_CONTRACT_ADDRESS
in./contract/constants.js
with the contract address printed out in the deploy script. Alternatively, you can set the FTR_CONTRACT_ADDRESS environment variable.
Note: You can run npm run compile
if you wish to just compile the contract but not deploy it.
- Run
npm start
to start the client - Open
localhost:8080
in your browser
To speed up development, you can utilize a few tools:
- Run
npm run dev
in one shell, andnode server.js
in another. Then openlocalhost:3000
. This will enable hot loading, so you can merely make a client side change and the site will auto-reresh with changes. - There are configurations in the .vscode folder to run the server and deploy script through visual studio in order to use a debugger.
One of the reasons we chose to build this as an express app was to make deployment easy.
The simplest way to deploy this sample is to use Heroku. The repository already has the necessary config files to run on Heroku (the Procfile and app.json).