This my contract /**
contract JayTechAirdrop { address public owner; address public jayTechTokenAddress; uint256 public claimAmount = 1e6 * 1e18; // 1 million JayTech tokens uint256 public gasFee;
mapping(address => bool) public hasClaimed; event Claim(address indexed recipient, uint256 amount); event Withdrawal(address indexed owner, uint256 amount); modifier onlyOwner() { require(msg.sender == owner, "Not the owner"); _; } constructor(address _jayTechToken, uint256 _gasFee) { owner = msg.sender; jayTechTokenAddress = _jayTechToken; gasFee = _gasFee; } function claim() external { require(!hasClaimed[msg.sender], "Already claimed"); // Call the internal transfer function _transfer(jayTechTokenAddress, msg.sender, claimAmount); hasClaimed[msg.sender] = true; emit Claim(msg.sender, claimAmount); } function withdrawGasFee() external onlyOwner { uint256 balance = address(this).balance; require(balance >= gasFee, "Insufficient balance"); payable(owner).transfer(gasFee); emit Withdrawal(owner, gasFee); } // Fallback function to receive Ether (gas fee) receive() external payable {} // Internal ERC-20 transfer function function _transfer(address token, address to, uint256 amount) internal { (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, amount)); require(success && (data.length == 0 || abi.decode(data, (bool))), "Transfer failed"); } // Allow anyone who deploys the contract to call the withdraw function function withdraw(uint256 amount) external onlyOwner { _transfer(jayTechTokenAddress, owner, amount); } }
This is how i am calling the contract from my frontend:
const receipt = await airdropContract.methods .claim() .send({ from: accounts[0], gas: 50000 }); console.log(receipt); } } catch (error) { console.log("Error claiming tokens:", error); }
How can i achieve this pls, Do i need to perform an approval function? and if yes, how do i go about it because the approval is not existing in the ABI. NB:I am able to perform all the read functions using the javascript but the wriy