Skip to content

Commit

Permalink
I add working mint button for HENO. new drop.
Browse files Browse the repository at this point in the history
  • Loading branch information
sweetmantech committed Jan 11, 2024
1 parent 45dde1e commit 940a809
Show file tree
Hide file tree
Showing 5 changed files with 2,439 additions and 2,305 deletions.
41 changes: 26 additions & 15 deletions hooks/useZoraMint.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { BigNumber, Contract } from "ethers"
import { BigNumber, Contract, utils } from "ethers"
import { useAccount } from "wagmi"
import { useConnectModal } from "@rainbow-me/rainbowkit"
import { toast } from "react-toastify"
import abi from "../lib/abi/zora-drop.json"
import { useEthersSigner } from "./useEthersSigner"
import handleTxError from "../lib/handleTxError"
import useCheckNetwork from "./useCheckNetwork"
import useSaleStatus from "./useSaleStatus"
import { CHAIN_ID } from "../lib/consts"

const useZoraMint = () => {
const signer = useEthersSigner({ chainId: CHAIN_ID })
const { publicSalePrice } = useSaleStatus()
const { checkNetwork } = useCheckNetwork()
const { isConnected, address } = useAccount()
const { openConnectModal } = useConnectModal()
const mintWithRewards = async () => {
const toastId = toast.info("Collecting...", {
autoClose: false
autoClose: false,
})
try {
if (!isConnected) {
Expand All @@ -29,24 +27,37 @@ const useZoraMint = () => {
}
const quantity = 1
const contract = new Contract(process.env.NEXT_PUBLIC_DROP_ADDRESS, abi, signer)
const zoraFee = await contract.zoraFeeForAmount(quantity)
const zoraFeeWei = zoraFee.fee
const zoraFeeWei = "777000000000000"
const comment = "!!!"
const mintReferral = process.env.NEXT_PUBLIC_MINT_REFERRAL
const tx = await contract.mintWithRewards(address, quantity, comment, mintReferral, {
value: BigNumber.from(publicSalePrice).add(zoraFeeWei).toString(),
gasLimit: 300293,
})
const minter = "0x04e2516a2c207e84a1839755675dfd8ef6302f0a"
const tokenId = 1
console.log("SWEETS ADDRESS", address)
const minterArguments = utils.defaultAbiCoder.encode(
["address", "string"],
[address, comment],
)
const tx = await contract.mintWithRewards(
minter,
tokenId,
quantity,
minterArguments,
mintReferral,
{
value: zoraFeeWei,
gasLimit: 300293,
},
)
const receipt = await tx.wait()
toast.update(toastId, {
render: 'Purchased',
type: toast.TYPE.SUCCESS,
autoClose: 3000,
});
render: "Purchased",
type: toast.TYPE.SUCCESS,
autoClose: 3000,
})
return receipt
} catch (err) {
toast.dismiss()
handleTxError({message: "Mint failed!"})
handleTxError({ message: "Mint failed!", error: err })
return { err }
}
}
Expand Down
Loading

0 comments on commit 940a809

Please sign in to comment.