Questions tagged [solidity-0.7.x]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

Verify result of gas expensive view calculation in transaction

I'm have an expensive view function which calculates rewards over time and investment. When it comes to withdrawing rewards I would need to run this, which could overrun gas for the block. Is there a ...
0
votes
1answer
35 views

Unary operator - cannot be applied to type uint256

I was trying to compile the mulDiv function, part of the uniswap-v3-core code base, but I am getting the following error: Unary operator - cannot be applied to type uint256 This is the line where it ...
1
vote
1answer
32 views

Remix Solidity Smart Contract Stuck On Compiling State

The 1inch Smart Contract is unable to compile in Remix as it appears to be stuck in the Solidity compiling phase. Expected Create a new 1inch_38211317.sol smart contract file in Remix. Compile the ...
0
votes
1answer
20 views

How can I test my purchase function on the truffle with chai?

I'm trying to test my token buying function but I encounter an error, o facilitate understanding I will show the code "Error: Returned error: VM Exception while processing transaction: revert&...
0
votes
1answer
15 views

Stack too deep error [duplicate]

Not sure what the best approach is to get around this. New to solidity. I've read the complicated 'answers' to this that suggest using structs, arrays, etc. but I can't figure out how to address this. ...
0
votes
1answer
27 views

Mapping keys optimization in Solidity

I've looked through all answers here but still have the question for the latest version of Solidity. Perhaps, there exist new libraries Is it possible to optimize this mapping(address => uint) ...
3
votes
1answer
243 views

SLOAD costs 800 gas - how is it possible?

I've got a very simple contract. It narrows down and measures cost of loading a storage variable: pragma solidity ^0.7.6; contract Bench { uint256 public data; function increment() ...
0
votes
1answer
18 views

Ethereum unimplemented feature

I am trying to compile this code: contract C { struct s { string chan; string content; } s[] x = new s[](0); } And it lands me with a confusing compiler error: ...
1
vote
0answers
17 views

Making function calls exclusive per block

I have the requirement that in my smart contract certain functions cannot be called, if another function already has been called inside the same contract during the same transaction. Imagine I have ...
0
votes
0answers
54 views

does the gasleft function return the total gas left for the transaction or the gas left for the function call

If a function is using the gasleft() function and is called by another smart contract, does it return the total gas left for the transaction or just the gas left passed to the function via the message ...
0
votes
0answers
19 views

override keyword usecase + what it does [duplicate]

function burn(uint tokens) override external returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(tokens); _totalSupply = _totalSupply.sub(tokens); emit ...
0
votes
0answers
18 views

Issuing 1-1 eth for token problem

pragma solidity 0.6.6; // import "./XYZToken.sol"; contract Vault { mapping(address => uint256) balanceOf; mapping(address => bool) hasDepositedEther; mapping(...
0
votes
1answer
31 views

Transfer funds to inherited smart contracts [closed]

How would I make this work - the balanceOf[Pool, System + Cube] doesn't seem to work ;-; // SPDX-License-Identifier: GPLv2 pragma solidity ^0.7.0; import "./Pool.sol"; import "./Cube....
1
vote
1answer
56 views

TypeError: Type string calldata slice is not implicitly convertible to expected type string memory

I want to slice a string and save it to a memory or storage variable. Is this possible? function test(string calldata _input) external{ string memory something = _input[1:3]; } I am ...
1
vote
1answer
100 views

Using inherited constructor in Solidity >=0.5.0

I want to use a contract inherit from another contract and use the parent constructor after using another commands in inherited constructor. So I wrote: pragma solidity ^0.5.10; contract A { ...
0
votes
1answer
67 views

“out of gas” when trying to send back ETH from a contract to tx.origin

(UPDATED) The contract should have more than enough ETH. I deploy the contract with 0.1 ETH: https://git.io/JUBdy const consumerExample = await ConsumerExampleFactory.deploy(process.env....