My javascript file just isn't working when I point to it in html

this is the html, it points to a javascript file <!DOCTYPE html> <html lang="en"> <head> <title>Fund me app</title> </head> <body> penis <script src="./index.js" type="text.javascript"> </script> <button id="connectButton" onclick="connect()"> Connect </button> </body> </html> this is index.js I’ve pointed the html code to it, but it just doesn’t run async function connect() { if (typeof window.ethereum !==… Read More My javascript file just isn't working when I point to it in html

Confused about a withdraw function in a contract I am studying

I am fairly new to Solidity and at this point, reviewing contracts that are active and on chain. I am trying to understand every detail. This withdraw function has got me stumped. function withdraw(address token, uint256 amount) external onlyOwner { if(token == address(0)) { payable(_msgSender()).transfer(amount); } else { IERC20(token).transfer(_msgSender(), amount); } } Particularly the two… Read More Confused about a withdraw function in a contract I am studying

How to get the amount of token sent to a smart contract via the fallback function in solidity

Let’s say I have a token A and a smart contract B. A user sent some amount of A to to the contract B by direct transfer through his wallet. In the fallback function of the smart contract B, how will I get the amount of token A that was sent? msg.value did’nt give me… Read More How to get the amount of token sent to a smart contract via the fallback function in solidity

What is the meaning of comma sequence like ,,,,, in Solidity?

I recently came across the following Solidity function: function testHealthFactor() public { (, , , , , uint256 healthFactor) = ILendingPool(lendingPool).getUserAccountData(user); console.log("health factor", healthFactor); assertEq(healthFactor < 1 ether, true); } I don’t know Solidity enought yet, so I wander what is the mining of that sequence of 5 commas? >Solution : Solidity allows you to… Read More What is the meaning of comma sequence like ,,,,, in Solidity?

couldn't declare solidity version in remix

I tried initializing solidity version but I get this error, how to di it right way paragma solidity ^0.8.14; error from solidity: ParserError: Expected ‘;’ but got ‘^’ –> .deps/SimpleStorage.sol:1:18: | 1 | paragma solidity ^0.8.14; | >Solution : should be pragma instead of paragma

How to make check if a key exists in mapping or not in Solidity when value is of type enum?

I have the following contract in solidity. // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; contract PocketCrypto { enum Role{ GUARDIAN, WARD} mapping(address => Role) public role; function setRole(Role _role) public { role[msg.sender] = _role; } } I want to check if for a given address a Role is set or not. But since default value for… Read More How to make check if a key exists in mapping or not in Solidity when value is of type enum?

Converstion error from uint to int in Solidity

I have been trying to learn solidity. Wrote a simple program as shown below pragma solidity >=0.8.12 <0.9.0; contract Test { int[] staticArray = [int(1), int(2), int(3), int(4), int(5)]; function getStaticArray(int _pos) public view returns(int) { int ret = staticArray[_pos]; return ret; } } But giving following conversation error for some reason: TypeError: Type int256… Read More Converstion error from uint to int in Solidity