I am making a casino for a client and I want to setup a wallet which will be used to pay for gas for all the information being uploaded on the contract.
I am using the private key to create a signer and then sending the transaction but for some reason the transaction is not being formed.
async function sendToContract() {
try {
const provider = new ethers.providers.Web3Provider(window.ethereum);
// Create a wallet instance from the private key
const wallet = new ethers.Wallet(privateKey, provider);
// Get the signer from the wallet instance
const signer = wallet.connect(provider);
const signer1 = provider.getSigner();
console.log(signer, signer1);
const contract = new ethers.Contract(contractAddress, abi, signer);
console.log("Contract:", contract);
await contract.setWithdrawAmount(ethers.utils.parseEther(String(user.unclaimed)), user.walletId).then((res)=>{console.log(res)}).catch((err)=>{console.log(err)});
} catch (err) {
console.log(err);
}
}
What am I doing wrong?
I am using ethers v5.7.2 Thanks! :)
Tried all chatbots and could find no info online.