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,19 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Collection Volume Hook
|
|
4
|
+
export const useFetchERC721CollectionVolume = async (port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
headers : {
|
|
10
|
+
'accept' : 'application/json'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Use the custom hook to fetch data
|
|
15
|
+
const state = useFetch(`http://localhost:${port}/erc721-collection-volume`, options);
|
|
16
|
+
|
|
17
|
+
// Return the state from the custom hook
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Holdings hook
|
|
4
|
+
export const useFetchERC721Holdings = async (walletAddress: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ walletAddress }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-holdings`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Lookup Data hook
|
|
4
|
+
export const useFetchERC721LookupData = async (contractAddress: string, tokenID: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ contractAddress, tokenID }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-lookup-data`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Opensea data hook
|
|
4
|
+
export const useFetchERC721OpenseaData = async (contractAddress: string, tokenID: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ contractAddress, tokenID }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-opensea-data`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Rarity data hook
|
|
4
|
+
export const useFetchERC721RarityData = async (contractAddress: string, tokenID: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ contractAddress, tokenID }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-rarity-data`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Sales data hook
|
|
4
|
+
export const useFetchERC721SalesData = async (contractAddress: string, tokenID: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ contractAddress, tokenID }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-sales-data`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Transfer Lookup data hook
|
|
4
|
+
export const useFetchERC721TransferLookupData = async (contractAddress: string, tokenID: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ contractAddress, tokenID }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-token-transfer-lookup-data`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Transfer data hook
|
|
4
|
+
export const useFetchERC721TransfersData = async (walletAddress: string, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ walletAddress }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc721-wallet-transfers`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching Address to ENS Custom hook
|
|
4
|
+
export const useFetchGasLookup = (port: number) => {
|
|
5
|
+
const URL = `http://localhost:${port}/gas-information`; // Define the API endpoint
|
|
6
|
+
|
|
7
|
+
const options = {
|
|
8
|
+
method: 'GET',
|
|
9
|
+
headers: {
|
|
10
|
+
'accept': 'application/json'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const state = useFetch(URL, options); // Use the custom hook to fetch data
|
|
15
|
+
|
|
16
|
+
return state; // Return the state from the custom hook
|
|
17
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC20 Prices Hook
|
|
4
|
+
export const useFetchERC20Price = async (contractAddress: string, currentPrice: boolean, duration: 2 | 14 | 30, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ contractAddress, currentPrice, duration }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/erc20-token-price`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ERC721 Prices Hook
|
|
4
|
+
export const useFetchERC721Price = async (contractAddress: string, tokenID: number, port: number) => {
|
|
5
|
+
// Set options for request
|
|
6
|
+
let options = {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
body: JSON.stringify({ contractAddress, tokenID }),
|
|
9
|
+
headers : {
|
|
10
|
+
'accept' : 'application/json'
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Use the custom hook to fetch data
|
|
15
|
+
const state = useFetch(`http://localhost:${port}/erc721-token-price`, options);
|
|
16
|
+
|
|
17
|
+
// Return the state from the custom hook
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
2
|
+
|
|
3
|
+
// Fetching ETH Prices Hook
|
|
4
|
+
export const useFetchETHPrice = async (currentPrice: boolean, duration: 2 | 14 | 30, port: number) => {
|
|
5
|
+
|
|
6
|
+
// Set options for request
|
|
7
|
+
let options = {
|
|
8
|
+
method: 'POST',
|
|
9
|
+
body: JSON.stringify({ currentPrice, duration }),
|
|
10
|
+
headers : {
|
|
11
|
+
'accept' : 'application/json'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Use the custom hook to fetch data
|
|
16
|
+
const state = useFetch(`http://localhost:${port}/eth-price`, options);
|
|
17
|
+
|
|
18
|
+
// Return the state from the custom hook
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LayerTwoNetworks } from "../../types/LayerTwoType";
|
|
2
|
+
import { useFetch } from "../../custom_hooks/useFetch";
|
|
3
|
+
|
|
4
|
+
// Fetching Layer Two Prices Hook
|
|
5
|
+
export const useFetchLayerTwoPrice = async (layerTwo: LayerTwoNetworks, currentPrice: boolean, duration: 2 | 14 | 30, port: number) => {
|
|
6
|
+
|
|
7
|
+
// Set options for request
|
|
8
|
+
let options = {
|
|
9
|
+
method: 'POST',
|
|
10
|
+
body: JSON.stringify({ layerTwo: LayerTwoNetworks[layerTwo], currentPrice, duration }),
|
|
11
|
+
headers : {
|
|
12
|
+
'accept' : 'application/json'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// Use the custom hook to fetch data
|
|
17
|
+
const state = useFetch(`http://localhost:${port}/layer-two-prices`, options);
|
|
18
|
+
|
|
19
|
+
// Return the state from the custom hook
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { FetchStateType } from '../types/FetchStateType';
|
|
3
|
+
|
|
4
|
+
// Custom hook for fetching data using the FETCH Client API
|
|
5
|
+
export const useFetch = <T = any>(URL: string, options: RequestInit = {}) => {
|
|
6
|
+
const [state, setState] = useState<FetchStateType<T>>({
|
|
7
|
+
data: null,
|
|
8
|
+
loading: false,
|
|
9
|
+
error: false
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// On useFetch call, make the appropriate API request
|
|
13
|
+
// Set the state accordingly
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
(async () => {
|
|
16
|
+
setState({ data: null, loading: true, error: false });
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(URL, options);
|
|
19
|
+
if (response.ok) {
|
|
20
|
+
const json = await response.json();
|
|
21
|
+
setState({ data: json, loading: false, error: false });
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
setState({ data: null, loading: false, error: true });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
setState({ data: null, loading: false, error: true });
|
|
29
|
+
}
|
|
30
|
+
})();
|
|
31
|
+
}, [URL]);
|
|
32
|
+
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export enum LayerTwoNetworks { // Added export keyword
|
|
2
|
+
Optimism = "optimism",
|
|
3
|
+
Arbitrum = "arbitrum",
|
|
4
|
+
Polygon = "matic-network",
|
|
5
|
+
ZkSync = "zksync",
|
|
6
|
+
ImmutableX = "immutable-x",
|
|
7
|
+
StarkNet = "starknet",
|
|
8
|
+
BobaNetwork = "boba-network",
|
|
9
|
+
Sushiswap = "sushi",
|
|
10
|
+
Metis = "metis-token",
|
|
11
|
+
HermezNetwork = "hermez-network-token",
|
|
12
|
+
CelerNetwork = "celer-network",
|
|
13
|
+
SynthetixSNXOnOptimism = "havven",
|
|
14
|
+
Deversifi = "devve",
|
|
15
|
+
Loopring = "loopring",
|
|
16
|
+
Biconomy = "biconomy",
|
|
17
|
+
BancorOnArbitrum = "bancor",
|
|
18
|
+
AaveOnOptimism = "aave",
|
|
19
|
+
PerpetualProtocol = "perpetual-protocol",
|
|
20
|
+
Cartesi = "cartesi",
|
|
21
|
+
Zora = "zora-bridged-weth-zora-network",
|
|
22
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
List of the 30 React Hooks
|
|
2
|
+
|
|
3
|
+
Prices
|
|
4
|
+
useFetchETHPrice - [Current Price, Duration]
|
|
5
|
+
useFetchERC20Price - [Contract Address, Current Price, Duration]
|
|
6
|
+
useFetchERC721Price - [Contract Address, Token ID]
|
|
7
|
+
useFetchLayerTwoPrice - [Layer Two Network, Current Price, Duration]
|
|
8
|
+
|
|
9
|
+
-
|
|
10
|
+
|
|
11
|
+
ERC20 Tokens
|
|
12
|
+
useFetchERC20CollectionOwners - [Contract Address]
|
|
13
|
+
useFetchERC20CollectionTopCoins - []
|
|
14
|
+
useFetchERC20CollectionTransfers - [Contract Address]
|
|
15
|
+
useFetchERC20Holdings - [Contract Address]
|
|
16
|
+
useFetchERC20Transfers - [Contract Address]
|
|
17
|
+
|
|
18
|
+
-
|
|
19
|
+
|
|
20
|
+
ERC721 Tokens
|
|
21
|
+
useFetchERC721CollectionAttributes - [Contract Address]
|
|
22
|
+
useFetchERC721CollectionData - [Contract Address]
|
|
23
|
+
useFetchERC721CollectionExtraData - [Contract Address]
|
|
24
|
+
useFetchERC721CollectionFloorPrice - [Contract Address]
|
|
25
|
+
useFetchERC721CollectionMarketCap - [Contract Address, Duration]
|
|
26
|
+
useFetchERC721CollectionSales - [Contract Address]
|
|
27
|
+
useFetchERC721CollectionTransfers - [Contract Address]
|
|
28
|
+
useFetchERC721CollectionTrends - []
|
|
29
|
+
useFetchERC721CollectionVolume - []
|
|
30
|
+
useFetchERC721Holdings - [Wallet Address]
|
|
31
|
+
useFetchERC721LookupData - [Contract Address, Token ID]
|
|
32
|
+
useFetchERC721OpenseaData - [Contract Address, Token ID]
|
|
33
|
+
useFetchERC721RarityData - [Contract Address, Token ID]
|
|
34
|
+
useFetchERC721SalesData - [Contract Address, Token ID]
|
|
35
|
+
useFetchERC721TransferLookupData - [Contract Address, Token ID]
|
|
36
|
+
useFetchERC721Transfers - [Wallet Address]
|
|
37
|
+
|
|
38
|
+
-
|
|
39
|
+
|
|
40
|
+
ENS
|
|
41
|
+
useFetchAddressENSLookup - [Address]
|
|
42
|
+
useFetchENSAddressLookup - [ENS Name]
|
|
43
|
+
useFetchENSIDLookup - [ID]
|
|
44
|
+
useFetchENSNameLookup - [ENS Name]
|
|
45
|
+
|
|
46
|
+
-
|
|
47
|
+
|
|
48
|
+
Gas
|
|
49
|
+
useFetchGasLookup - []
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ethereum-hooks",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Package containing useful React hooks for working with the Ethereum Blockchain.",
|
|
5
|
+
"main": "server/server.ts",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"start": "ts-node server/server.ts",
|
|
8
|
+
"client": "cd client && npm start",
|
|
9
|
+
"build": "cd client && npm run build",
|
|
10
|
+
"install-all": "cd client && npm install && cd ../server && npm install",
|
|
11
|
+
"build-server": "tsc -p server/tsconfig.json",
|
|
12
|
+
"test": "echo \"No tests specified\" && exit 0"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"api",
|
|
16
|
+
"blockchain",
|
|
17
|
+
"client",
|
|
18
|
+
"crypto",
|
|
19
|
+
"ethereum",
|
|
20
|
+
"expressjs",
|
|
21
|
+
"hooks",
|
|
22
|
+
"nodejs",
|
|
23
|
+
"reactjs",
|
|
24
|
+
"server"
|
|
25
|
+
],
|
|
26
|
+
"author": "CodingAbdullah",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"private": false,
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"ts-node": "^10.9.0",
|
|
31
|
+
"typescript": "^5.7.2"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"ethereum-hooks": "file:"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require("dotenv").config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
// Address to ENS information
|
|
6
|
+
export const addressToENSInformation = (req: Request, res: Response) => {
|
|
7
|
+
const { address } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
const MORALIS_URL = 'https://deep-index.moralis.io/api/v2/';
|
|
10
|
+
const options = {
|
|
11
|
+
method: 'GET',
|
|
12
|
+
mode: 'cors', // *cors, same-origin
|
|
13
|
+
headers: {
|
|
14
|
+
'content-type' : 'application/json',
|
|
15
|
+
'access-control-allow-origin': '*',
|
|
16
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY // Transpose API key hidden
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Making back-end request call for information
|
|
21
|
+
axios.get(MORALIS_URL + 'resolve/' + address + "/reverse", options)
|
|
22
|
+
.then(response => {
|
|
23
|
+
res.status(200).json({
|
|
24
|
+
information: response.data
|
|
25
|
+
})
|
|
26
|
+
})
|
|
27
|
+
.catch(() => {
|
|
28
|
+
res.status(400).json({});
|
|
29
|
+
})
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
// ENS Transfers By ID
|
|
6
|
+
export const ensTransfersById = (req: Request, res: Response) => {
|
|
7
|
+
const { id } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
const params = {
|
|
10
|
+
chain_id : 'ethereum',
|
|
11
|
+
token_id: id
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const options = {
|
|
15
|
+
headers: {
|
|
16
|
+
'accept' : 'application/json',
|
|
17
|
+
'content-type': 'application/json',
|
|
18
|
+
'X-API-KEY' : process.env.TRANSPOSE_API_KEY
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Making back-end request call to fetch data
|
|
23
|
+
axios.get('https://api.transpose.io/ens/ens-transfers-by-token-id?' + new URLSearchParams(params), options)
|
|
24
|
+
.then(response => {
|
|
25
|
+
res.status(200).json({
|
|
26
|
+
information: response.data
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
.catch(() => {
|
|
30
|
+
res.status(400).json({});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
// ENS Transfers By Name
|
|
6
|
+
export const ensTransfersByName = (req: Request, res: Response) => {
|
|
7
|
+
const { ensName } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
const params = {
|
|
10
|
+
chain_id : 'ethereum',
|
|
11
|
+
ens_name: ensName
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const options = {
|
|
15
|
+
headers: {
|
|
16
|
+
'accept' : 'application/json',
|
|
17
|
+
'content-type': 'application/json',
|
|
18
|
+
'X-API-KEY' : process.env.TRANSPOSE_API_KEY
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Making back-end request call for information
|
|
23
|
+
axios.get('https://api.transpose.io/ens/ens-transfers-by-name?' + new URLSearchParams(params), options)
|
|
24
|
+
.then(response => {
|
|
25
|
+
res.status(200).json({
|
|
26
|
+
information: response.data
|
|
27
|
+
});
|
|
28
|
+
})
|
|
29
|
+
.catch(() => {
|
|
30
|
+
res.status(400).json({});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require('dotenv').config({ path: '../.env' });
|
|
2
|
+
import { Request, Response } from 'express'
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
|
|
5
|
+
// ENS to Address Controller
|
|
6
|
+
export const additionalENSInformation = (req: Request, res: Response) => {
|
|
7
|
+
const { ensName } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
const params = {
|
|
10
|
+
"chain_id": "ethereum",
|
|
11
|
+
"ens_names": ensName,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const options = {
|
|
15
|
+
headers: {
|
|
16
|
+
'accept' : 'application/json',
|
|
17
|
+
'content-type': 'application/json',
|
|
18
|
+
'X-API-KEY' : process.env.TRANSPOSE_API_KEY
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Making back-end request call for information
|
|
23
|
+
axios.get("https://api.transpose.io/ens/ens-records-by-name?" + new URLSearchParams(params), options)
|
|
24
|
+
.then(response => {
|
|
25
|
+
res.status(200).json({
|
|
26
|
+
information: response.data
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
.catch(() => {
|
|
30
|
+
res.status(400).json({});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -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 Owners data
|
|
6
|
+
export const ERC20CollectionOwnersController = (req: Request, res: Response) => {
|
|
7
|
+
const { contractAddress } = JSON.parse(req.body.body);
|
|
8
|
+
|
|
9
|
+
// Add ERC20 Collection Owners 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 Owners Controller
|
|
20
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/erc20/' + contractAddress + '/owners?chain=eth&order=DESC', 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,27 @@
|
|
|
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 Top Coins data
|
|
6
|
+
export const ERC20CollectionTopCoinsController = (req: Request, res: Response) => {
|
|
7
|
+
// Add ERC20 Top Coins Controller data parameters
|
|
8
|
+
const options = {
|
|
9
|
+
method: 'GET',
|
|
10
|
+
headers: {
|
|
11
|
+
'accept': 'application/json',
|
|
12
|
+
'content-type': 'application/json',
|
|
13
|
+
'X-API-KEY' : process.env.MORALIS_API_KEY
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Conditionally making API calls for ERC20 Top Coins Controller
|
|
18
|
+
axios.get('https://deep-index.moralis.io/api/v2.2/market-data/erc20s/top-tokens', options)
|
|
19
|
+
.then(response => {
|
|
20
|
+
res.status(200).json({
|
|
21
|
+
information: response.data
|
|
22
|
+
});
|
|
23
|
+
})
|
|
24
|
+
.catch(() => {
|
|
25
|
+
res.status(400).json({});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -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 ERC20CollectionTransfersController = (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.2/erc20/" + 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
|
+
}
|