ethereum-hooks 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +246 -0
- package/client/package.json +25 -0
- package/client/src/crypto_hooks/ens/useFetchAddressENSLookup.ts +18 -0
- package/client/src/crypto_hooks/ens/useFetchENSAddressLookup.ts +19 -0
- package/client/src/crypto_hooks/ens/useFetchENSIDLookup.ts +18 -0
- package/client/src/crypto_hooks/ens/useFetchENSNameLookup.ts +18 -0
- package/client/src/crypto_hooks/erc20Tokens/useFetchERC20CollectionOwners.ts +20 -0
- package/client/src/crypto_hooks/erc20Tokens/useFetchERC20CollectionTopCoins.ts +19 -0
- package/client/src/crypto_hooks/erc20Tokens/useFetchERC20CollectionTransfers.ts +20 -0
- package/client/src/crypto_hooks/erc20Tokens/useFetchERC20Holdings.ts +20 -0
- package/client/src/crypto_hooks/erc20Tokens/useFetchERC20Transfers.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionAttributes.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionExtraData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionFloorPrice.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionMarketCap.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionSales.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionTransfers.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionTrends.ts +19 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721CollectionVolume.ts +19 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721Holdings.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721LookupData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721OpenseaData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721RarityData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721SalesData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721TransferLookupData.ts +20 -0
- package/client/src/crypto_hooks/erc721Tokens/useFetchERC721TransfersData.ts +20 -0
- package/client/src/crypto_hooks/gas/useFetchGasLookup.ts +17 -0
- package/client/src/crypto_hooks/prices/useFetchERC20Price.ts +20 -0
- package/client/src/crypto_hooks/prices/useFetchERC721Price.ts +19 -0
- package/client/src/crypto_hooks/prices/useFetchETHPrice.ts +20 -0
- package/client/src/crypto_hooks/prices/useFetchLayerTwoPrice.ts +21 -0
- package/client/src/custom_hooks/useFetch.ts +34 -0
- package/client/src/types/FetchStateType.ts +6 -0
- package/client/src/types/LayerTwoType.ts +22 -0
- package/hook-server-design.png +0 -0
- package/hooksinformation.txt +49 -0
- package/package.json +36 -0
- package/server/Controller/ENS/AddressToENSController.ts +30 -0
- package/server/Controller/ENS/ENSIDController.ts +32 -0
- package/server/Controller/ENS/ENSNameController.ts +32 -0
- package/server/Controller/ENS/ENSToAddressController.ts +32 -0
- package/server/Controller/ERC20Tokens/ERC20CollectionOwnersController.ts +29 -0
- package/server/Controller/ERC20Tokens/ERC20CollectionTopCoinsController.ts +27 -0
- package/server/Controller/ERC20Tokens/ERC20CollectionTransfersController.ts +29 -0
- package/server/Controller/ERC20Tokens/ERC20HoldingsController.ts +29 -0
- package/server/Controller/ERC20Tokens/ERC20TransfersController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionAttributesController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionDataController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionExtraDataController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionFloorPriceController.ts +18 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionMarketCapController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionSalesController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionTransfersController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionTrendsController.ts +28 -0
- package/server/Controller/ERC721Tokens/ERC721CollectionVolumeController.ts +28 -0
- package/server/Controller/ERC721Tokens/ERC721HoldingsController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721LookupDataController.ts +28 -0
- package/server/Controller/ERC721Tokens/ERC721OpenseaDataController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721RarityDataController.ts +29 -0
- package/server/Controller/ERC721Tokens/ERC721SalesDataController.ts +34 -0
- package/server/Controller/ERC721Tokens/ERC721TransferLookupDataController.ts +28 -0
- package/server/Controller/ERC721Tokens/ERC721TransfersDataController.ts +29 -0
- package/server/Controller/Gas/GasLookupController.ts +26 -0
- package/server/Controller/Prices/ERC20PriceController.ts +43 -0
- package/server/Controller/Prices/ERC721PriceController.ts +28 -0
- package/server/Controller/Prices/ETHPriceController.ts +42 -0
- package/server/Controller/Prices/LayerTwoPriceController.ts +41 -0
- package/server/Routes/ENSRoutes/AddressToENSRoute.ts +9 -0
- package/server/Routes/ENSRoutes/ENSIDRoute.ts +8 -0
- package/server/Routes/ENSRoutes/ENSNameRoute.ts +9 -0
- package/server/Routes/ENSRoutes/ENSToAddressRoute.ts +9 -0
- package/server/Routes/ERC20TokensRoutes/ERC20CollectionOwnersRoute.ts +9 -0
- package/server/Routes/ERC20TokensRoutes/ERC20CollectionTopCoinsRoute.ts +9 -0
- package/server/Routes/ERC20TokensRoutes/ERC20CollectionTransfersRoute.ts +9 -0
- package/server/Routes/ERC20TokensRoutes/ERC20HoldingsRoute.ts +9 -0
- package/server/Routes/ERC20TokensRoutes/ERC20TransfersRoute.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionAttributesRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionExtraDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionFloorPriceRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionMarketCapRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionSalesRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionTransfersRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionTrendsRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721CollectionVolumeRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721HoldingsRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721LookupDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721OpenseaDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721RarityDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721SalesDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721TransferLookupDataRoutes.ts +9 -0
- package/server/Routes/ERC721TokensRoutes/ERC721TransfersDataRoutes.ts +9 -0
- package/server/Routes/GasRoutes/GasLookupRoute.ts +9 -0
- package/server/Routes/PriceRoutes/ERC20PriceRoute.ts +9 -0
- package/server/Routes/PriceRoutes/ERC721PriceRoute.ts +9 -0
- package/server/Routes/PriceRoutes/ETHPriceRoute.ts +9 -0
- package/server/Routes/PriceRoutes/LayerTwoPriceRoute.ts +9 -0
- package/server/package.json +25 -0
- package/server/server.ts +53 -0
- package/server/tsconfig.json +109 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC20 Collection Holdings data
|
|
6
|
+
export const ERC20HoldingsController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC20 Collection Holdings Controller Holdings data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC20 Collection Holdings Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2/' + contractAddress + '/erc20?chain=eth', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC20 Collection Transfers data
|
|
6
|
+
export const ERC20TransfersController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC20 Collection Transfers Controller data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC20 Collection Transfers Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2/' + contractAddress + '/erc20/transfers?chain=eth', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Attributes data
|
|
6
|
+
export const ERC721CollectionAttributesController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Collection Attributes Controller data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC721 Collection Attributes Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/nft/' + contractAddress + '/traits', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Data
|
|
6
|
+
export const ERC721CollectionDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Collection Controller Data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC721 Collection Data Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2/nft' + contractAddress, options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Extra Collection Data
|
|
6
|
+
export const ERC721CollectionExtraDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Collection Controller Extra Data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC721 Collection Extra Data Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/nft/' + contractAddress + '/metadata', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
const sdk = require('api')('@alchemy-docs/v1.0#3yq3i17l9sqr4d6'); // SDK ID for Alchemy package found through docs
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Floor Price Data
|
|
6
|
+
export const ERC721CollectionFloorPriceController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
// Run backend request
|
|
9
|
+
sdk.server('https://eth-mainnet.g.alchemy.com/nft/v2');
|
|
10
|
+
|
|
11
|
+
sdk.getFloorPrice({ apiKey: process.env.ALCHEMY_API_KEY, contractAddress })
|
|
12
|
+
.then((response: any) =>
|
|
13
|
+
res.status(200).json({ information: response })
|
|
14
|
+
)
|
|
15
|
+
.catch(() => {
|
|
16
|
+
res.status(400).json({});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Market Cap Controller data
|
|
6
|
+
export const ERC721CollectionMarketCapController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, duration } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Collection Market Cap Controller data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Conditionally making API calls for ERC721 Collection Market Cap Controller
|
|
19
|
+
axios.get('https://api.coingecko.com/api/v3/coins/ethereum/contract/' + contractAddress +
|
|
20
|
+
'/market_chart?vs_currency=usd&days=' + duration + '&interval=daily', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Sales Controller data
|
|
6
|
+
export const ERC721CollectionSalesController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Collection Market Cap Controller data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC721 Collection Sales Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2/nft/' + contractAddress + '/trades', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Transfers Controller data
|
|
6
|
+
export const ERC721CollectionTransfersController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Collection Transfers Controller data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC721 Collection Transfers Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2/nft' + contractAddress + '/transfers', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Trends Controller data
|
|
6
|
+
export const ERC721CollectionTrendsController = (req: Request, res: Response) => {
|
|
7
|
+
|
|
8
|
+
// Add ERC721 Collection Trends Controller data parameters
|
|
9
|
+
const options = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: {
|
|
12
|
+
'accept': 'application/json',
|
|
13
|
+
'content-type': 'application/json',
|
|
14
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Conditionally making API calls for ERC721 Collection Trends Controller
|
|
19
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/market-data/nfts/hottest-collections', options)
|
|
20
|
+
.then(response => {
|
|
21
|
+
res.status(200).json({
|
|
22
|
+
information: response.data
|
|
23
|
+
});
|
|
24
|
+
})
|
|
25
|
+
.catch(() => {
|
|
26
|
+
res.status(400).json({});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Collection Volume Controller data
|
|
6
|
+
export const ERC721CollectionVolumeController = (req: Request, res: Response) => {
|
|
7
|
+
|
|
8
|
+
// Add ERC721 Collection Volume Controller data parameters
|
|
9
|
+
const options = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: {
|
|
12
|
+
'accept': 'application/json',
|
|
13
|
+
'content-type': 'application/json',
|
|
14
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Conditionally making API calls for ERC721 Collection Volume Controller
|
|
19
|
+
axios.get('"https://deep-index.moralis.io/api/v2.2/market-data/nfts/top-collections', options)
|
|
20
|
+
.then(response => {
|
|
21
|
+
res.status(200).json({
|
|
22
|
+
information: response.data
|
|
23
|
+
});
|
|
24
|
+
})
|
|
25
|
+
.catch(() => {
|
|
26
|
+
res.status(400).json({});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Holdings Controller data
|
|
6
|
+
export const ERC721HoldingsController = (req: Request, res: Response) => {
|
|
7
|
+
const { walletAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 Holdings Controller data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Conditionally making API calls for ERC721 Holdings Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/' + walletAddress + '/nft/collections?chain=eth', options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Lookup Data Controller
|
|
6
|
+
export const ERC721LookupDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, tokenID } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
const options = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: {
|
|
12
|
+
'accept' : 'application/json',
|
|
13
|
+
'content-type': 'application/json',
|
|
14
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Making request to Moralis API for finding ERC721 token lookup information
|
|
19
|
+
axios.get('https://deep-index.moralis.io/api/v2/nft/' + contractAddress + "/" + tokenID + "?chain=eth" + "&format=decimal", options)
|
|
20
|
+
.then(response =>
|
|
21
|
+
res.status(200).json({
|
|
22
|
+
information: response.data
|
|
23
|
+
})
|
|
24
|
+
)
|
|
25
|
+
.catch(() => {
|
|
26
|
+
res.status(400).json({});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Opensea Data Controller
|
|
6
|
+
export const ERC721OpenseaDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, tokenID } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Setting options to make authenticated API calls to retrieve ERC721 Opensea token information
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept' : 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.OPENSEA_API_KEY
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Making request to Opensea API to retrieve ERC721 Opensea token information
|
|
20
|
+
axios.get('https://api.opensea.io/api/v2/chain/ethereum/contract' + contractAddress + '/nfts/' + tokenID, options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: [response.data]
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Rarity Data Controller
|
|
6
|
+
export const ERC721RarityDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, tokenID } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Setting options to make authenticated API calls to retrieve ERC721 token rarity information
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept' : 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Making request to Alchemy API for finding ERC721 token rarity
|
|
20
|
+
axios.get('https://eth-mainnet.g.alchemy.com/nft/v2/' + process.env.ALCHEMY_API_KEY + "/computeRarity?contractAddress=" + contractAddress + "&tokenId=" + tokenID, options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: { data: response.data }
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Sales data Controller
|
|
6
|
+
export const ERC721SalesDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, tokenID } = JSON.parse(req.body.body); // Parse information for make API call
|
|
8
|
+
|
|
9
|
+
// Setting params and options for ERC721 token sales data
|
|
10
|
+
const params = {
|
|
11
|
+
"chain_id": "ethereum",
|
|
12
|
+
"contract_address": contractAddress,
|
|
13
|
+
"token_id": tokenID
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const options = {
|
|
17
|
+
headers: {
|
|
18
|
+
'accept' : 'application/json',
|
|
19
|
+
'content-type': 'application/json',
|
|
20
|
+
'X-API-KEY' : process.env.TRANSPOSE_API_KEY
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Making request to Transpose API for finding ERC721 token sales information
|
|
25
|
+
axios.get("https://api.transpose.io/nft/sales-by-token-id?" + new URLSearchParams(params), options)
|
|
26
|
+
.then(response => {
|
|
27
|
+
res.status(200).json({
|
|
28
|
+
information: response.data
|
|
29
|
+
});
|
|
30
|
+
})
|
|
31
|
+
.catch(() => {
|
|
32
|
+
res.status(400).json({});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Transfer Lookup data Controller
|
|
6
|
+
export const ERC721TransferLookupDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, tokenID } = JSON.parse(req.body.body); // Parse information for make API call
|
|
8
|
+
|
|
9
|
+
const options = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: {
|
|
12
|
+
'accept' : 'application/json',
|
|
13
|
+
'content-type': 'application/json',
|
|
14
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Making request to Moralis API for finding ERC721 Token Transfer Lookup information
|
|
19
|
+
axios.get('https://deep-index.moralis.io/api/v2/nft/' + contractAddress + "/" + tokenID + '/transfers?chain=eth&format=decimal', options)
|
|
20
|
+
.then(response =>
|
|
21
|
+
res.status(200).json({
|
|
22
|
+
information: response.data
|
|
23
|
+
})
|
|
24
|
+
)
|
|
25
|
+
.catch(() => {
|
|
26
|
+
res.status(400).json({});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Transfers data Controller
|
|
6
|
+
export const ERC721TransfersDataController = (req: Request, res: Response) => {
|
|
7
|
+
const { walletAddress } = JSON.parse(req.body.body); // Parse information for make API call
|
|
8
|
+
|
|
9
|
+
// Pass in API key for backend request
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept' : 'application/json',
|
|
14
|
+
'content-type': 'application/json',
|
|
15
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
axios.get('https://deep-index.moralis.io/api/v2/' + walletAddress +
|
|
20
|
+
'/nft/transfers?chain=eth&format=decimal&direction=both', options) // Pass in address and chain values
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from "express";
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching Ethereum gas information
|
|
6
|
+
export const gasTrackInformation = (req: Request, res: Response) => {
|
|
7
|
+
|
|
8
|
+
// Add blocknative credentials
|
|
9
|
+
const options = {
|
|
10
|
+
method: 'GET',
|
|
11
|
+
headers: {
|
|
12
|
+
'content-type': 'application/json',
|
|
13
|
+
'Authorization' : process.env.BLK_API_KEY
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
axios.get('https://api.blocknative.com/gasprices/blockprices', options)
|
|
18
|
+
.then(response => {
|
|
19
|
+
res.status(200).json({
|
|
20
|
+
information: response.data
|
|
21
|
+
})
|
|
22
|
+
})
|
|
23
|
+
.catch(() => {
|
|
24
|
+
res.status(400).json({});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC20 Pricing information
|
|
6
|
+
export const ERC20PriceController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, currentPrice, duration } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC20 price options data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'accept': 'application.json',
|
|
14
|
+
'content-type': 'application/json'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Conditionally fetching ERC20 pricing
|
|
19
|
+
if (currentPrice) {
|
|
20
|
+
axios.get('https://api.coingecko.com/api/v3/coins/ethereum/contract/' + contractAddress, options)
|
|
21
|
+
.then(response => {
|
|
22
|
+
res.status(200).json({
|
|
23
|
+
information: response.data
|
|
24
|
+
});
|
|
25
|
+
})
|
|
26
|
+
.catch(() => {
|
|
27
|
+
res.status(400).json({});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// Conditionally making API calls for ERC20 Pricing
|
|
32
|
+
axios.get('https://api.coingecko.com/api/v3/coins/ethereum/contract/' + contractAddress +
|
|
33
|
+
'/market_chart?vs_currency=usd&days=' + duration + '&interval=daily', options)
|
|
34
|
+
.then(response => {
|
|
35
|
+
res.status(200).json({
|
|
36
|
+
information: response.data
|
|
37
|
+
});
|
|
38
|
+
})
|
|
39
|
+
.catch(() => {
|
|
40
|
+
res.status(400).json({});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from "axios";
|
|
4
|
+
|
|
5
|
+
// Controller function for fetching ERC721 Pricing information
|
|
6
|
+
export const ERC721PriceController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress, tokenID } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC721 price options data parameters
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
headers: {
|
|
13
|
+
'content-type': 'application/json',
|
|
14
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Conditionally making API calls for ERC721 Pricing
|
|
19
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/nft/' + contractAddress + '/' + tokenID + '/floor-price?chain=eth', options)
|
|
20
|
+
.then(response => {
|
|
21
|
+
res.status(200).json({
|
|
22
|
+
information: response.data
|
|
23
|
+
});
|
|
24
|
+
})
|
|
25
|
+
.catch(() => {
|
|
26
|
+
res.status(400).json({});
|
|
27
|
+
});
|
|
28
|
+
}
|