-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockchain-requests.js
53 lines (48 loc) · 1.72 KB
/
blockchain-requests.js
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
import { useWeb3Contract, useMoralis } from "react-moralis";
import GameContract from "./constants/frontEndAbiLocation/GameContract.json";
import IpfsNFT from "./constants/frontEndAbiLocation/IpfsNFT.json";
import Marketplace from "./constants/frontEndAbiLocation/Marketplace.json";
import networkMapping from "./constants/networkMapping.json";
export const useGameContract = () => {
const { web3, account } = useMoralis();
const price = "10000000000000000";
const { runContractFunction: cancelItem } = useWeb3Contract({
abi: Marketplace,
contractAddress:
networkMapping[web3.currentProvider.networkVersion]["Marketplace"],
functionName: "cancelItem",
params: {
nftAddress:
networkMapping[web3.currentProvider.networkVersion]["IpfsNFT"],
tokenId: tokenId,
},
});
const { runContractFunction: updateItem } = useWeb3Contract({
abi: Marketplace,
contractAddress:
networkMapping[web3.currentProvider.networkVersion]["Marketplace"],
functionName: "updateItem",
params: {
nftAddress:
networkMapping[web3.currentProvider.networkVersion]["IpfsNFT"],
tokenId: tokenId,
updatedPrice: price,
},
});
const { runContractFunction: getAmountOwned } = useWeb3Contract({
abi: Marketplace,
contractAddress:
networkMapping[web3.currentProvider.networkVersion]["Marketplace"],
functionName: "getAmountOwned",
params: {},
});
const { runContractFunction: getTokenUris } = useWeb3Contract({
abi: IpfsNFT,
contractAddress:
networkMapping[web3.currentProvider.networkVersion]["IpfsNFT"],
functionName: "getTokenUris",
params: {
index: tokenId,
},
});
};