mint NFT from client

This commit is contained in:
Ruidy 2022-04-07 19:31:06 -04:00
parent e222193365
commit 25f0e40cc8
2 changed files with 396 additions and 2 deletions

View file

@ -1,7 +1,8 @@
import "./App.css"; import "./App.css";
import {} from "ethers"; import { providers, Contract } from "ethers";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { withEth } from "./lib/eth"; import { withEth } from "./lib/eth";
import epicNFT from "./lib/epicNFT.json";
function App() { function App() {
const [currentAccount, setCurrentAccount] = useState(""); const [currentAccount, setCurrentAccount] = useState("");
@ -20,7 +21,18 @@ function App() {
setCurrentAccount(accounts[0]); setCurrentAccount(accounts[0]);
}); });
const mintNFT = withEth(async (ethereum) => {}); const mintNFT = withEth(async (ethereum) => {
const contractAddress = process.env.REACT_APP_STAGING_CONTRACT_ADDRESS;
const contractABI = epicNFT.abi;
const signer = new providers.Web3Provider(ethereum).getSigner();
const contract = new Contract(contractAddress, contractABI, signer);
const txn = await contract.mint();
console.log(`Mining ${txn.hash}`);
await txn.wait();
console.log(`Minted. See transaction: https://rinkeby.etherscan.io/tx/${txn.hash}`);
});
useEffect(() => { useEffect(() => {
checkIfWalletConnected(); checkIfWalletConnected();

382
client/src/lib/epicNFT.json Normal file

File diff suppressed because one or more lines are too long