Hot answers tagged

3

Came to know that WSL-2 cannot connect to the localhost directly. See this and this. WSL-2 has its own port to listen to. Ganache gives you the option to select that port instead of localhost. Go to Settings > Server > Hostname > 172.23.160.1 - Ethernet (WSL) Can use the command provided by @Ismael above in the comments to check if the port is ...


2

Before swaping a token (such as WETH), you have to approve a sufficient amount to the router address. Use the approve() function of the token contract before attempting the swap.


2

I encountered the same error when solving the same Ethernaut level. I'm using Remix IDE. When I changed from deploying with JavaScript VM to deploying with Injected Web3 (there's a dropdown menu in DEPLOY & RUN TRANSACTIONS in Remix and you need MetaMask to deploy this way), the error disappeared. I added the following function to the contract: ...


2

As per the error message and logs it looks like you're passing invalid arguments --- (argument="address", value="1000000", code=INVALID_ARGUMENT, version=address/5.4.0) The address argument expects an address type argument, but you're passing a number (1000000) instead. (argument=null, value="1000000", code=INVALID_ARGUMENT, ...


1

Division by zero is an exception that will result in a reverted transaction. function foo(uint num, uint den) public pure returns(uint result) { if(den == 0) return 0; // there is no "correct" result, so decide what to do result = num / den; } There are other subtleties around division - no floats, precision, truncation - setting those aside ...


1

From the question contract I can say that it wont compile given the position of the public keyword, should look like this: pragma solidity ^0.4.13; contract nietTeveel{ uint public maxbedrag = 50; uint public restbedrag; function stortencheck () payable{ if (msg.value >= maxbedrag){ ...


1

You have typo in function definition it should be returns instead of return. function transferFrom(address from, address to, uint value) public returns(bool)


1

From the documentation: Transfers tokens from the targeted address to the given destination Errors with 'STF' if transfer fails STF stands for safeTransferFrom. So there is an error when transferring the tokens. It is likely you didn't execute the approve() function before doing the swap. Or you didn't approve() enough of the token you are trying to swap.


1

This is because there is stuff in your directory already. You can either: Force create the directory brownie init --force Which will create the brownie sample directory alongside your existing code/contracts/.venv file. Remove everything in that directory rm -rf * brownie init Create a new folder with your brownie project mkdir brownie_project cd ...


1

It is a typo in your code: numberslist.length


1

This is the placeholder sign used for libraries. Maybe you're not providing the correct libraries?  The evm replaces the substring between the $ symbols with the library address during compilation. If the libraries are not provided then the resulting bytecode still has the placeholders. (Credit for this answer goes to Viktor from Tenderly, thanks a lot!)


1

I had the same issue for that tutorial looks like once the test is ran it adds an import for react-bootstrap/lib/Breadcrumb. I just removed the import and reran the test and it worked.


1

Solidity v0.8.4 to the rescue! // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.4; error Unauthorized(); contract VendingMachine { address payable owner = payable(msg.sender); function withdraw() public { if (msg.sender != owner) { revert Unauthorized(); } owner.transfer(address(this).balance); } ...


1

It is a warning, Etherscan is looking for the Transfer(sender,recipient,amount) event and it can't find it because ERC223 uses slightly different event Transfer(sender,recipient,amount,data). It shouldn't be a problem. Perhaps a wallet that is not aware of ERC223 tokens will not update the balance correctly, but the balance should be correct on the ...


1

This answer is about nightly builds in general and not specific to solidity. A nightly build, in general, is a build of a version, that is not finished yet. So there might be more bugs or missing features. It is basically a build of the current work in progress. It is called nightly build because it is common to automatically build them from the current ...


1

You error is not related to nightly builds. One of your files (SafeMath.sol) requires a compiler version (pragma solidity ^0.4.23) lower than the one you selected (0.8.3).


1

"The called function should be payable" is a wild guess of a hint and usually wrong. The contract has reverted for any number of reasons. You will have to use debugging techniques to zero in on the actual cause which could be array index out of bounds, divide by zero, one of the requires isn't happy, etc. I made it as far as Item.sellItem(). As a ...


1

you should open the contract file and klick on compile


1

You changed the gas limit to 32000 which is too low for this function to operate.. the $8 cannot be refunded. Simple example (1 gas is 1 lego piece) To build a house you need 150000 lego pieces (just a number I don't really know how much it costs) but you sent in your transaction only 32000 lego pieces, which is not enough. The contract does not know exactly ...


1

I'm embarrassed to report that I found my problem. It had nothing to do with the Truffle contract abstraction or web3.js contract object. The problem was in the web3.js function estimateGas. This function doesn't just give you a gas estimate, it simulates the transaction and so throws any errors that the function call would throw when used in anger. So, when ...


Only top voted, non community-wiki answers of a minimum length are eligible