Skip to content

Commit

Permalink
Merge pull request #3 from rhaicode/function-development
Browse files Browse the repository at this point in the history
mint function added
  • Loading branch information
kavinm authored Dec 30, 2021
2 parents b1efc4e + 7ec3490 commit 2421100
Showing 1 changed file with 13 additions and 26 deletions.
39 changes: 13 additions & 26 deletions src/components/Landing/YourWallet/Minting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,36 +30,23 @@ const Minting: React.FC = () => {
const [mintAmount, setMintAmount] = useState(1)

const askContractToMintNFT = async (amount: number) => {
try {
const { ethereum } = window as any
const { ethereum } = window as any

if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum)
const signer = provider.getSigner()
const connectedContract = new ethers.Contract(
GOD_CONTRACT_ADDRESS,
GodContract.abi,
signer
)
if (ethereum) {
const provider = new ethers.providers.Web3Provider(ethereum)
const signer = provider.getSigner()
const connectedContract = new ethers.Contract(
GOD_CONTRACT_ADDRESS,
GodContract.abi,
signer
)

const totalPrice = String(MINT_PRICE * amount)
const ethersValue = { value: ethers.utils.parseEther(totalPrice) }
const totalPrice = String(MINT_PRICE * amount)
const ethersValue = { value: ethers.utils.parseEther(totalPrice) }

console.log('Going to pop wallet now to pay mint fee and gas...')
const nftTxn = await connectedContract.mint(amount, false, ethersValue)

const nftTxn = await connectedContract.mint(amount, false, ethersValue)

console.log('Mining...please wait.')
await nftTxn.wait()

console.log(
`Mined, see transaction: https://rinkeby.etherscan.io/tx/${nftTxn.hash}`
)
} else {
console.log("Ethereum object doesn't exist!")
}
} catch (error) {
console.log(error)
await nftTxn.wait()
}
}

Expand Down

1 comment on commit 2421100

@vercel
Copy link

@vercel vercel bot commented on 2421100 Dec 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.