Questions tagged [solidity-0.7.x]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
10 views

How do I check for empty bytes array?

In 0.7.6 I want to check if a bytes array is equal to "" or not, but the compiler doesn't like bytes fingerprint = ""; if(fingerprint!=""){ // do something } How do I ...
0
votes
0answers
20 views

How do i get the price of an erc20 token from solidity smart contract [duplicate]

I'm building a dapp, i'm trying to get the erc20 token price in usd from my smart contract how do i go about this? this is very necessary as smart contracts cannot read from outside networks. I don't ...
0
votes
1answer
23 views

How to store mapping with inline assembly?

I have a special needs, store the mapping with assembly code. thank you very for everyone who can response this question. for example: contract assemblyMappingTest{ mapping(address => uint) ...
0
votes
1answer
24 views

How do you interface with a lower version of solidity

I'm trying to create a contract (solidity version 0.7.6) that interacts with some arbitrary contract of a lower version (0.4.21). However, I have been trying to declare an interface in (0.7.6) but it ...
0
votes
0answers
4 views

parsing error in smartcontract constructor

parsing error in smartcontract constructor, can some one please help me out and show me what I am doing wring and why this error is even thought everytrhing is looking fine from outside.
0
votes
1answer
21 views

why do i keep getting these error messages on remix IDE on compilation?

ALERT: Transaction Error. Exception thrown in contract code. I have tried all i could // SPDX-License-Identifier: MIT pragma solidity >=0.7.0 <0.9.0; interface IERC20Token { function transfer(...
0
votes
0answers
8 views

Create Contracts from a Contract and Push it to an Array (Solidity 0.7.0 or higher)?

So basically, I'm using Remix and I have two contracts AuctionManager and BlindedAuction/Auction The auction manager will run first and it holds an array of addresses, whenever a beneficiary creates ...
1
vote
1answer
28 views

call method in compiler 0.8

how can i change this for older compiler versions like 0.4.24? (bool success, ) = transaction.to.call{value: transaction.value}(transaction.data); and if you have time please explain to me the call ...
0
votes
0answers
9 views

How to delete an item in an array of uint256 [duplicate]

I'm using solodity 0.7 and have an array of uint256 so is there away to delete an item in this array?
0
votes
1answer
131 views

How to send an amount of ether from the smart contract to an address and save any information along with the transaction (in the TX DATA) (solidity)

I need to send a certain quality of ether from the smart contract to an address, but the problem is that I need that along with that transaction I need information to be recorded in the blockchain for ...
0
votes
1answer
38 views

Factory pattern for multiple contracts inheriting from same abstract contract exceeds size

I have a base abstract contract which is inherited by 3 other contracts (all having the same interface). I am trying to use a factory contract to conditionally create instances of the derived ...
0
votes
0answers
40 views

How to use OpenZepplin hooks to cancel transfer if condition is not met?

I am experimenting with OpenZepplin Hooks to modify ERC20 transfer functions in this way contract IToken is ERC20 { .... function _beforeTokenTransfer(address from, address to, uint256 amount) ...
1
vote
1answer
243 views

How to initialize and assign value to constant in constructor?

I have the following code and want to initialize a constant in constructor. import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract IToken is ERC20 { uint256 private ...
2
votes
2answers
22 views

Can I write a function to edit an enum?

I have an enum with certain predefined data. If at a later date, I have to add or push in more choices , can I edit the enum using some function ? enum ActionChoices { GoLeft, GoRight, GoStraight, ...
0
votes
0answers
11 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 ...
2
votes
1answer
601 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
221 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
157 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
18 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
47 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
717 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
27 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
47 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
1answer
231 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
27 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
20 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
47 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
161 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
300 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
107 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....