"use client"; import { Header, Loader } from "@/components"; import NotePicker from "@/components/TextEditor/NotePicker"; import React, { useState } from "react"; import { FaWandMagicSparkles } from "react-icons/fa6"; import { ethers } from "ethers"; import { useRouter } from "next/router"; import { blockchainList, random } from "@/libs/constant"; import Link from "next/link"; import { addQuestionToTableFn } from "@/libs/TablelandFnCall"; import { addQuestionFn } from "@/libs/contractFunctionCall"; const tagsData = [ { id: 1, tag: "smart-contracts" }, { id: 2, tag: "solidity" }, { id: 3, tag: "ethers.js" }, { id: 4, tag: "truffle" }, { id: 5, tag: "eth-wallet" }, { id: 6, tag: "ether" }, { id: 7, tag: "ethereum-classic" }, { id: 8, tag: "gas" }, { id: 9, tag: "blockchain" }, { id: 10, tag: "erc-20" }, { id: 11, tag: "Defi" }, { id: 12, tag: "metamask" }, { id: 13, tag: "ganache" }, { id: 14, tag: "web3.py" }, { id: 16, tag: "filecoin" }, { id: 17, tag: "ipfs" }, { id: 18, tag: "tableland" }, { id: 19, tag: "fil" }, { id: 20, tag: "filecoin-mining" }, ]; const Ask = () => { const router = useRouter(); const [bountyFlag, setBountyFlag] = useState(false); const [loader, setLoader] = useState(false); const [tags, setTags] = useState([]); const [title, setTitle] = useState(""); const [poolBounty, setpoolBounty] = useState(""); const [winnerBounty, setWinnerBounty] = useState(""); const [deadline, setDeadline] = useState(""); const [content, setContent] = useState(""); const handleSubmit = async (e) => { e.preventDefault(); setLoader(true); if (bountyFlag) document.getElementById("my_modal_4").showModal(); const provider = new ethers.providers.Web3Provider(window.ethereum); await provider.send("eth_requestAccounts", []); const signer = await provider.getSigner(); const account = await signer.getAddress(); // console.log(title, tags, content); // Code here= if (!bountyFlag) { } setLoader(false); }; const submitForm = (event) => { event.preventDefault(); handleSubmit(event); }; const handleBountySubmit = async () => { console.log(poolBounty, winnerBounty, deadline, typeof deadline); setLoader(true); const provider = new ethers.providers.Web3Provider(window.ethereum); await provider.send("eth_requestAccounts", []); const signer = await provider.getSigner(); const account = await signer.getAddress(); console.log(deadline, Math.floor(new Date().getTime() / 1000)); const data = { questionId: random(), addr: account, questionText: title, details: content, tags: JSON.stringify(tags), timeOfCreation: new Date().toISOString(), timeBased: 1, timeAllotted: deadline, upvote: 0, downvote: 0, }; console.log(data); await addQuestionToTableFn(signer, data); console.log(ethers.utils.parseEther(winnerBounty, "ether")); const _bountyPool = Number(ethers.utils.parseUnits(poolBounty, "ether")); const _mainBounty = Number(ethers.utils.parseUnits(winnerBounty, "ether")); await addQuestionFn(signer, { _questionId: data.questionId, _bountyBased: true, _mainBounty, _bountyPool, _timeOfBounty: Math.floor(new Date().getTime() / 1000), }); router.push(`/questions/${data.questionId}`); setLoader(false); }; return (
{loader && }

Ask Public Question

{tags.map((item, index) => (
{item}
))}
Body Include all information someone would need to answer your question
Ask AI

Add Bounty

{loader ? ( ) : ( )}
); }; export default Ask;