set gasLimit in useWeb3Contract
hook Nextjs
#5078
-
In the lesson 10: NextJS Smart Contract Lottery (Full Stack / Front End) we use const {
runContractFunction: enterRaffle,
isLoading,
isFetching,
} = useWeb3Contract({
abi: abi,
contractAddress: raffleAddress!, // specify the networkId
functionName: "enterRaffle",
params: {},
msgValue: entranceFee,
}) I use this method to call my own contract, but due to The question is where / how can i set this parameter ? I do not found answer in the thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Maybe like this:
|
Beta Was this translation helpful? Give feedback.
-
@Belingheri You can add the gas configurations in the hardhat.config.js file for the network you are working on. And this error also happens due to the error in the processing (logic) of code so check it as well. |
Beta Was this translation helpful? Give feedback.
-
thanks to @alymurtazamemon
I switch to thirdweb, this lib have the import { useContractWrite, useContract, Web3Button } from "@thirdweb-dev/react";
import { ethers } from "ethers";
// Your smart contract address
const contractAddress = "{{contract_address}}";
function App() {
const { contract } = useContract(contractAddress);
const { mutateAsync, isLoading, error } = useContractWrite(
contract,
"setName",
);
return (
<Web3Button
contractAddress={contractAddress}
action={() =>
mutateAsync([
"My Name",
{
gasLimit: 1000000, // override default gas limit
value: ethers.utils.parseEther("0.1"), // send 0.1 ether with the contract call
},
])
}
>
Send Transaction
</Web3Button>
);
}
export default App; |
Beta Was this translation helpful? Give feedback.
thanks to @alymurtazamemon
I switch to thirdweb, this lib have the
gasLimit
option: