i have created a function that should allow me to join a channel for a price. this is like some on and off type of thing. It worked yesterday and now it doesnt want to work. I am pulling my hair out trying to figure out the issue.. I am using ethersjs 5.7.2.
const handleServerJoin = async (serverId: any, cost: any) => {
try {
const provider = new ethers.providers.Web3Provider(window?.ethereum as any);
const signer = provider.getSigner();
const contractInstance = new ethers.Contract(
contractAddress,
ABI.abi,
signer
);
// Convert cost to Ether
const etherDD = ethers.utils.formatEther(cost)
const joingServer = await contractInstance.joinChannel(serverId, {
value: ethers.utils.parseEther(etherDD.toString()),
gasPrice: ethers.utils.parseUnits('100', 'gwei'),
gasLimit: 800000,
})
alert("Joining server")
await joingServer.wait()
alert(`joined server ${joingServer.hash}` )
} catch (error) {
console.log(error)
return null
}
}
Alrighty so my cost value that i get from the parameters isa big number. i format it into a ether value then parse it into wei. i set the gas limit but i get an error. i add a gas price and kept add more since the transaction kept failing.
my reason behind why it is failing is because the network maybe conjusted or im just some dumbass who can do anything with his life.
This is the error message..
Error: transaction failed [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (transactionHash="0x7525ff09ad337ef6ce674e6a0982423457bc0641f17441d6afdbf0dbcd0ca846", transaction={"hash":"0x7525ff09ad337ef6ce674e6a0982423457bc0641f17441d6afdbf0dbcd0ca846","type":2,"accessList":null,"blockHash":null,"blockNumber":null,"transactionIndex":null,"confirmations":0,"from":"0x610aC7169092c2120f20B3b04d8452fa5a90c774","gasPrice":{"type":"BigNumber","hex":"0x174876e800"},"maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x174876e800"},"maxFeePerGas":{"type":"BigNumber","hex":"0x174876e800"},"gasLimit":{"type":"BigNumber","hex":"0x0c3500"},"to":"0x95790A17f7177b1B534Ed76D493E33094988c100","value":{"type":"BigNumber","hex":"0x2aa1efb94e0000"},"nonce":29,"data":"0x43bf5bb90000000000000000000000000000000000000000000000000000000000000002","r":"0x60295103b6d72780e2dbc4c71505823e3e3336c013c56f6bba08799fc9a20037","s":"0x5f50e43abe12eac0147a4445bb77f0b85b833f03af8c40afc3887fb45b19bdc3","v":0,"creates":null,"chainId":0}, receipt={"to":"0x95790A17f7177b1B534Ed76D493E33094988c100","from":"0x610aC7169092c2120f20B3b04d8452fa5a90c774","contractAddress":null,"transactionIndex":0,"gasUsed":{"type":"BigNumber","hex":"0x67a5"},"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","blockHash":"0xa9cae3019f15da10c67ea823c57d369225710d9afb55ab6401f7c35123fe3069","transactionHash":"0x7525ff09ad337ef6ce674e6a0982423457bc0641f17441d6afdbf0dbcd0ca846","logs":[],"blockNumber":5083781,"confirmations":2,"cumulativeGasUsed":{"type":"BigNumber","hex":"0x67a5"},"effectiveGasPrice":{"type":"BigNumber","hex":"0x174876e800"},"status":0,"type":2,"byzantium":true}, code=CALL_EXCEPTION, version=providers/5.7.2) at Logger.makeError (webpack-internal:///(app-pages-browser)/./node_modules/@ethersproject/logger/lib.esm/index.js:231:23) at Logger.throwError (webpack-internal:///(app-pages-browser)/./node_modules/@ethersproject/logger/lib.esm/index.js:240:20) at Web3Provider.eval (webpack-internal:///(app-pages-browser)/./node_modules/@ethersproject/providers/lib.esm/base-provider.js:1388:24) at Generator.next () at fulfilled (webpack-internal:///(app-pages-browser)/./node_modules/@ethersproject/providers/lib.esm/base-provider.js:28:58)
This is my smart contract function too if that helps... which i dont know.. dont think thatd be the problem.
function joinChannel(uint32 channelId) public payable {
require(channelId != 0);
require(channelId <= totalChannels);
require(hasJoined[channelId][msg.sender] == true, "soorry you already joined..");
// check joineded...
require(msg.value >= channels[channelId].cost, "Sorry you need a little more");
hasJoined[channelId][msg.sender] = true;
channels[channelId].users.push(msg.sender);
userChannels[msg.sender].push(channels[channelId]);
emit UserJoinedChannel(msg.sender, channelId);
}
```
Dont mind the comment..