-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
54 lines (45 loc) · 1.44 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Imports the Typechain bindings for Token.sol
import { Token__factory, TTBank__factory } from "@kimanikelly/core-contracts";
// Imports the Rinkeby addresses for Token.sol and TTBank.sol
import rinkebyAddress from "@kimanikelly/core-contracts/dist/addresses/4.json";
import goerliAddress from "@kimanikelly/core-contracts/dist/addresses/5.json";
("");
// Imports Express
import express from "express";
// Initializes Express
const app = express();
// Defines the port the Express server will serve on
const port = process.env.PORT || 3001;
// The home endpoint returns the endpoints for /token and /ttBank
app.get("/", (req, res) => {
res.status(200).json({
tokenEndpoint: "/token",
ttBankEndpoint: "/ttBank",
});
});
// GET request to return the address, abi, and bytecode of Token.sol
app.get("/token", (req, res) => {
res.status(200).json({
addresses: {
rinkeby: rinkebyAddress.token,
goerli: goerliAddress.token,
},
abi: Token__factory.abi,
bytecode: Token__factory.bytecode,
});
});
// GET request to return the address, abi, and bytecode of TTBank.sol
app.get("/ttBank", (req, res) => {
res.status(200).json({
addresses: {
rinkeby: rinkebyAddress.ttBank,
goerli: goerliAddress.ttBank,
},
abi: TTBank__factory.abi,
bytecode: TTBank__factory.bytecode,
});
});
// Starts the Express server
app.listen(port, () => {
console.log(`Listening on port: http://localhost:${port}`);
});