Project Setup
This sections covers how to setup your example project.
For this demo we assume such a project setup:
Type the following commands in the truffle project you created before:
1
mkdir web
2
cd web
3
npm init
4
mkdir src
5
cd src
6
touch hmy.js init.js userWallet.js index.html
7
cd ..
Copied!

Install Dependencies

1
npm i @harmony-js/contract @harmony-js/core @harmony-js/utils parcel-bundler
Copied!

Add Scripts

1
"scripts": {
2
"test": "echo \"Error: no test specified\" && exit 1",
3
"server": "http-server",
4
"dev": "parcel src/index.html "
5
},
Copied!
Or you can just copy-paste the following into your package.json file:
1
{
2
"name": "web",
3
"version": "1.0.0",
4
"description": "Demo to interact with harmony web wallets",
5
"main": "index.js",
6
"scripts": {
7
"test": "echo \"Error: no test specified\" && exit 1",
8
"server": "http-server",
9
"dev": "parcel src/index.html "
10
},
11
"author": "Rachit Anand",
12
"license": "ISC",
13
"dependencies": {
14
"@harmony-js/contract": "^0.1.55",
15
"@harmony-js/core": "^0.1.55",
16
"@harmony-js/utils": "^0.1.55",
17
"eslint": "^7.13.0",
18
"eslint-config-prettier": "^6.15.0",
19
"eslint-plugin-import": "^2.22.1",
20
"http-server": "^0.12.3",
21
"parcel-bundler": "^1.12.4",
22
"prettier": "^2.1.2"
23
},
24
"browserslist": [
25
"last 2 Firefox versions",
26
"last 2 Chrome versions"
27
]
28
}
29
Copied!

Put this into your index.html file

1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="UTF-8">
5
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6
<title>Document</title>
7
</head>
8
<body>
9
<input id="inputt">
10
<button id="inputtButton">Wallet</button>
11
<script src="./init.js"></script>
12
</body>
13
</html>
Copied!
Last modified 9mo ago