Hot answers tagged

2

There is a missing closing bracket in the following line v := byte(0, mload(add(_sign, 96)). The line should end with ")))". v := byte(0, mload(add(_sign, 96)))


2

It is rather unintuitive on Remix, but there is a value input near the top of the panel (circled red). You can enter the value there before clicking on a function call. You'll need to do it for every call as the input field clears after a transaction.


1

The function modifier is checked before the function. _; essentially states that the rest of the function can be executed here. It might be tempting to think that this is unnecessary. However, what's often missed is that there could be code after _; modifier noReentrancy() { require(!locked, "No reentrancy"); locked = true; _; ...


1

If you have the source code of the Smart Contract, you can follow the below-listed steps. Connect Web3 on Rinkeby network Compile your Smart Contract Go to deploy and run section in the Remix IDE Select your smart contract in the CONTRACT dropdown Under the Deploy button, you'll be able to see "At Address" 6. Paste your contract address (The one ...


1

The issue is because of the wrong placement of the }. contract SimpleStorage { address Address; string name; } Because of this, the contract, technically ends after declaring the name string. Everything else is considered to be outside the contract, hence you got the error. However, there are a couple more issues in the code, unrelated to this error....


1

The are 2 reasons this is failing. Transfer() gas limit address.transfer() has a gas limit of 2100. Its enough for emitting an event but not enough for victim.withdraw() in the fallback function. You can change it to (bool success,) = payable(msg.sender).call{value:amount}(""); Overflow check in v0.8.0 Solidity v0.8.0 has introduced an implicit ...


1

The reason is that you aren't depositing any amount to the contract. deposit function just takes in an int and updates the balance. You send ether to the contract, you need to make it payable and deduce the amount from msg.value. function deposit() public payable { balances[msg.sender] += msg.value; } Now if you try to withdraw, it should work properly.


1

I tell you what is wrong: the dev in front of the screen (facepalm) The parameter in the constructor of the attacker contract uses tokenContract as name. This shadows the state variable, which leads to the problem. Here the corrected code: // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; import "./Token.sol"; contract ...


1

Its easy. Instead of hard coding the amount, you just put a variable in it. Take a look at code below which takes an address and amount from user, and then sends the amount to the given address: function payFromContract (address payable _recipient, uint _amount) external { _recipient.transfer(_amount); }


1

This repo has an ERC 1155 implementation with EIP 2981 royalties; for an ERC 721, you'd just need to import IERC2981 and then add the royaltyInfo function and supportsInterface override to the token contract.


1

In addition to Ismael's answer, you actually CAN delete from array with shrinking. If order does not matter in your case, you may move element from last position to the one you want to delete, and then simply do .pop() on the array. This essentially picks last item from the array and shrinks it by one. See example based on Ismael's: // Assume we have data: [...


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