Questions tagged [solidity-0.5.x]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features. Solidity version 0.5.0 is a specific version that includes a number of changes to the language and introduce new features.

Filter by
Sorted by
Tagged with
1 vote
1 answer
23 views

Call or assignment expected. Getting this error while upgrading solidity version

I am not aware of the Assembly code. I copied the ERC1820 registry contract from here. This is written in 0.5.3. When I tried to compile it with 0.8.0 it gave me this error : I know it's because of ...
Serenity's user avatar
1 vote
1 answer
24 views

how to revert transaction excuted by low level call

Hello ethereum community. I'm experimenting with low level calls and i want to revert the transaction made by low level call, if i didn't get the desired result. Is it possible? (bool success, ) = ...
Biruk Damte's user avatar
1 vote
1 answer
28 views

Compiler doesn't show a warning if empty function is not marked as pure

When compiling a function without marking its state mutability as pure, the compiler shows the following warning: Warning: Function state mutability can be restricted to pure For example: contract ...
BonisTech's user avatar
  • 536
0 votes
1 answer
207 views

Flash Loan Transaction

Please I need help here, I am new to flash loans. I want to understand flash loan transactions on ether scan , how to identify them, if the transaction make profit or not. I am trying to implement a ...
Soyaya's user avatar
  • 31
0 votes
0 answers
13 views

Difference between deployed object and current object?

I have a problem understanding the concept of deployed object. Kindly follow the link: Executing reentrancy on Truffle Console: attacker not stealing 5 ether , why only 2 reentrant calls? The link ...
zak100's user avatar
  • 1,416
0 votes
0 answers
26 views

Truffle Exec Script: VM Exception While Executing (commented line#10) Require

I am trying to execute the following SC: 1.pragma solidity ^0.5.16; 2.contract SSUE2 { 3.address public owner; 4.bool public paused; 5.constructor() public { 6.owner = msg.sender; ...
zak100's user avatar
  • 1,416
1 vote
1 answer
30 views

The current timestamp is 0x5000. What is the smallest future timestamp that would win the game?

The current timestamp is 0x5000. What is the smallest future timestamp that would win the game?
user108304's user avatar
0 votes
1 answer
53 views

Truffle console: Can't Retrieve Solidity send(..) and transfer(..) from SC code

I have written a program for Truffle console. My code accesses the string and should return statements related to Solidity send and transfer. When I am testing each line of Solidity SC as shown below,...
zak100's user avatar
  • 1,416
2 votes
0 answers
115 views

ParserError: Expected '{' but got reserved keyword 'override' ) external override returns (bool) { ^------^

Can someone fix the code problem below? I compile in remix.ethereum.org , it show ParserError: Expected ';' but got '}' } external override The code: pragma solidity 0.5.8; /** Ropsten instances:...
funny cartoon's user avatar
0 votes
3 answers
686 views

BigNumber error

I started learning solidity but when I use construct im getting the error, please help: here's the code pragma solidity >=0.7.0 <0.9.0; contract base{ uint data; constructor (uint ...
adi kaushik's user avatar
0 votes
1 answer
101 views

i cant refund my BNB from my contract on remix [duplicate]

my bnb stuck and I cant back it to my wallet! here is the code I used https://ghostbin.com/KgvTS/raw my address https://bscscan.com/address/0xf3321b8f53ed3051fd4f0ae139f04fd6a280c4b7#internaltx
sodo's user avatar
  • 1
1 vote
1 answer
43 views

Converting from Version 4 to Version 5: Problem with Compilation

I got the following Solidity code from: https://www.zupzup.org/smart-contract-interaction/ pragma solidity ^0.5.6; contract Caller { function someAction(address addr) returns(uint) { ...
zak100's user avatar
  • 1,416
0 votes
1 answer
65 views

Remix's documented test test#2 fails

Why the remix’s documented test#2 fails? Hi, I am following the remix’s example test available at: https://remix-ide.readthedocs.io/en/latest/unittesting_examples.html. The sender code is: pragma ...
zak100's user avatar
  • 1,416
1 vote
1 answer
154 views

Sending Ether to contracts at object creation: Remix IDE

I am trying to send Ether to 2 Solidity contracts (version 0.5.3) using Remix IDE at the time of object creation. I am using following 2 techniques but getting compilation error: First Method: ...
zak100's user avatar
  • 1,416
0 votes
1 answer
102 views

how to test internal variables

I have a contract: contract SS { address payable commissions = payable(0x...02); function doStuff() public payable { (bool success, ) = payable(commissions).call{value: msg.value * 30 / ...
Nika Kurashvili's user avatar
0 votes
1 answer
406 views

How to access mapping array and address of contract in truffle test

I have 3 contracts: sender, receiver and transferTest. I am getting error in transferTest due to an address array declared in the reciver contract: receiver.sol: pragma solidity ^0.5.8; contract ...
zak100's user avatar
  • 1,416
0 votes
2 answers
749 views

Cannot import most libraries out there due to their compiler version being too old

My Contract has pragma solidity ^0.8.0; but I am using this library to be able to split strings that uses pragma solidity ^0.5.0;. Changing this line alone wont fix the issue, it will create new ones (...
PedroD's user avatar
  • 167
0 votes
1 answer
406 views

Why is array.length giving "length" not found or not visible after argument-dependent lookup in mapping?

Here's how I defined an array of my struct: struct FoodItem { string name; uint price; bool available; } mapping(uint => FoodItem) public foods; Now I want to delete an ...
Shourya Shikhar's user avatar
1 vote
1 answer
515 views

How to tell how much money executing something will cost

I understand the difference between transaction costs and execution costs, but I don't understand two things: What does the "gas" readout in Remix refer to? How do I create an estimate of ...
Pro Q's user avatar
  • 113
3 votes
0 answers
181 views

Include library function without function body

Using solc 0.5.0 it's possible to compile a contract that has a library function implemented with no body. For example: library Hasher { function MiMCSponge(uint256 in_xL, uint256 in_xR) external ...
GeraldHost's user avatar
3 votes
4 answers
10k views

Error HH411: The library openzeppelin-solidity is not installed. Try installing it using npm (for old 0.5.0 solidity code)

I have solidity project with files like pragma solidity ^0.5.0; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; When I try to compile, I get error on not installed library ...
Paul Verest's user avatar
1 vote
0 answers
97 views

Compiler version not recognized

Anyone have any ideas how to fix this? Compiler version is there. $ solc --optimize --abi ./contracts/MySmartContract.sol -o build ./contracts/MySmartContract.sol:1:1: Warning: Source file does not ...
pigfox's user avatar
  • 125
2 votes
1 answer
905 views

What is the logic by which tokens are ordered when creating a new Uniswap V2 pair?

When creating a new pair contract via the UniswapV2Factory contract, the order in which tokens get assigned in storage (that is, the token0 and token1 vars) cannot be arbitrarily set by the caller: (...
Paul Razvan Berg's user avatar
0 votes
1 answer
139 views

Ethereum DApp with user authentication

I'm creating a healthcare DApp and how can I create user authentication ( For Doctor and Patient). I'm using JavaScript and HTML for most of my UI.
Tafara Rodgers Magumise's user avatar
0 votes
1 answer
396 views

I can't compile my solidity contract, can someone help correct the code. i've been trying for about 24 hours now

This is my smart contract: pragma solidity ^0.5.0; contract Agent { struct patient { string name; string dob; address[] doctorAccessList; uint[] diagnosis; ...
Tafara Rodgers Magumise's user avatar
1 vote
1 answer
225 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 ...
ali's user avatar
  • 41
1 vote
1 answer
211 views

Storing constants in Storage vs Creating a view function? (Solidity 0.5.17)

So, which would be gas efficient? Reading a storage variable in a state-changing function? OR Reading from a pure function in a state-changing function? Example: contract Test { uint256 public a = ...
remedcu's user avatar
  • 338
0 votes
1 answer
49 views

I need to understand a line of code inside a contract => startTime: _startTime == 0 ? currentTime() : _startTime

I am reading a contract from this location : https://gist.github.com/rstormsf/7cfb0c6b7a835c0c67b4a394b4fd9383 I am not able to understand the logic in the code line 72 startTime: _startTime == 0 ? ...
Ashish kumar's user avatar
0 votes
1 answer
244 views

Contract pay the rest of gas fee

This is my payable public method1 : //Do sth if (condition) method2(); and as you know, if method2 is called, the user should pay the gas fee for it as well. How can call method2 from inside the ...
Pooya Taheri's user avatar
0 votes
0 answers
259 views

Truffle test is failling with transferFrom.call

When I run tests with the following code, I get the following error: Error Error: Returned error: VM Exception while processing transaction: revert Tests it('Handles delegated token transfers', () =...
Eladiorocha's user avatar
0 votes
0 answers
456 views

How can a contract accept some ether and send a stablecoin in return

My contract has to take ETH as a collateral and send some stablecoins ( like USDC) to user. How can I use any stablecoin into my contract , assuming contract has an infinite supply of USDC ? I too ...
Ashish kumar's user avatar
2 votes
2 answers
589 views

Member "owner" not found or not visible after argument-dependent lookup in type

pragma solidity ^0.5.0; contract reeler{ uint public id; string public name; string public addres; string public state; string public pincode; uint public yarncount = 0; mapping(uint =&...
Deeksha shetty's user avatar
0 votes
1 answer
220 views

how to get array that contain certain value

I'm new in solidity, I want to ask, in my case I want to store a data that may contain the same user ID but different value inside it each transaction, here is my smart contract: pragma solidity 0.5; ...
unknown.person's user avatar
0 votes
0 answers
337 views

Transfer ether in solidity 0.5.16 with truffle

I am currently working with Truffle and Ganache, therefore I use Solidity compiler version 0.5.16. With that version I have some problems to send ethers. I want to transfer ether to a specific address....
currImid's user avatar
1 vote
2 answers
1k views

How to ensure that a string parameter to a function is not empty?

Lets say that I have a function which needs two string parameter , function data(string memory _firstname, string memory _lastname) public { buyer[msg.sender] = Buyer(_firstname, _lastname); } Now, I ...
Ashish kumar's user avatar
0 votes
1 answer
698 views

Gas fee optimization questions [duplicate]

Can some recommend a way to save gas fees? a = a + 1; a++; I heard about this; Pack struct tightly Mine looks like this. I am not sure about size of address, ENUM variables and array without length. ...
ericobi's user avatar
  • 116
0 votes
0 answers
758 views

Validation of integers on solidity

I have this function and require the _price variable to be positive, But when I pass a negative int, it accepts the integer! How can I validate the input? The Contract : function createProduct(string ...
Pooya Taheri's user avatar
1 vote
2 answers
845 views

How to I initialise an array inside the contructor in solidity?

I'm using the remix IDE.I want to define the size of the array at the time constructor is called. Someone please help. This is what I tried : pragma solidity >=0.7.0 <0.8.0; contract Vote { ...
Vasvi Sood's user avatar
1 vote
1 answer
763 views

What's wrong with my buyToken function?

Here is my solidity interface IERC20 { function decimals() external view returns (uint8); function totalSupply() external view returns (uint); function balanceOf(address owner) external ...
Prosperity's user avatar
0 votes
1 answer
532 views

require(msg.sender.call("")): No matching declaration found after argument-dependent lookup

I am trying to compile the following Solidity program: pragma solidity ^0.5.9; contract Mutex { bool locked; modifier noReentrancy() { require(!locked); locked = true; ...
zak100's user avatar
  • 1,416
0 votes
1 answer
1k views

Remix: ParserError: Expected pragma. import directive, or contract/library/interface definition

I'm trying to use Remix to interact with a suite of contracts. One of the contracts being used is OpenZeppelin's Ownable contract. I copied from the link above, and pasted it into Remix, with a few ...
The Renaissance's user avatar
0 votes
0 answers
32 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(...
Lucus's user avatar
  • 107
0 votes
1 answer
206 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....
Lucus's user avatar
  • 107
1 vote
1 answer
1k 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 { ...
Alireza Zojaji's user avatar
1 vote
0 answers
382 views

How to call the super contract function where msg.sender should be same in solidity?

I am trying to call contract A.fun_A() via Contract C contract A{ function fun_A(address tenant, uint itemId){ //Here the msg.sender should be msg.sender in C require(msg.sender == ...
jiswok's user avatar
  • 11
0 votes
3 answers
58 views

Get a blank address

I have a little problem with my code. I'm trying to follow who are the current sender and the previous sender of a transaction respectively with the variable currentSender and lastSender, and then ...
Rayan Barbara's user avatar
0 votes
1 answer
466 views

Getter of mapping inside a struct

I wanted to create a getter function to access a mapping nested inside a struct. But the function that I made required me to use the expiremental version (I'm on Remix). So I used the expiremental ...
Rayan Barbara's user avatar
0 votes
1 answer
41 views

Else if structure gives the wrong output

I have a little problem with a else if struture that doesn't give out the right result. Here is the code: pragma solidity >=0.5.16; contract SupChain{ enum StateType {A, B, C} ...
Tameiki's user avatar
0 votes
0 answers
44 views

Negative integer function

I have the following problem, one of my function has a variable where the uint can be negative but I don't know of that before the user enter in the form the integer. How do I settle this problem ? ...
Tameiki's user avatar
0 votes
1 answer
1k views

Warning! Error encountered during contract execution [execution reverted]

I have an ERC20 Mintable+Burnable Token created on solidity 6.11 and a sale contract on solidity 5.0 I am getting error when i send ETH to the sale contract. https://rinkeby.etherscan.io/tx/...
VagueRumi's user avatar