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
0
votes
1answer
7 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 = ...
0
votes
1answer
17 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 ? ...
0
votes
0answers
9 views

Function overloading problem

As we know, it's possible to distinguish between two functions have same names. Different number of the functions arguments is a way for that. If the number of arguments is the same but the set of the ...
0
votes
1answer
13 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 ...
0
votes
0answers
11 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', () =...
0
votes
0answers
17 views

How to add data to an array inside a struct?

I have made a struct which contains an array . Now when I am adding data to the struct, I'm not able to add data to the array . struct User { uint256 limit; // spending limit uint256 ...
0
votes
0answers
15 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 ...
0
votes
1answer
12 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 =&...
0
votes
1answer
48 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; ...
0
votes
0answers
36 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....
0
votes
2answers
13 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 ...
0
votes
1answer
58 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. ...
0
votes
0answers
27 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 ...
0
votes
0answers
7 views

error when I run truffle test

TypeError: Cannot read property 'call' of undefined at Context. (test/TdetayProofTest.js:18:74) here my test: var TdetayProof = artifacts.require("./TdetayProof.sol"); contract('TdetayProof',...
0
votes
0answers
15 views

What is the purpose of EVM tags, their haphazard arrangement and their relationship to functions?

I want to understand the purpose of tags in EVM assembly and their relationship with Solidity function. pragma solidity ^0.5.1; import './Mod.sol'; contract MOFTest{ ModifiedBank mb; ...
0
votes
2answers
42 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 { ...
0
votes
1answer
144 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 ...
0
votes
1answer
31 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; ...
0
votes
1answer
197 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 ...
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....
0
votes
0answers
55 views

Solidity 0.5.0, issue related to transfer function

I am using the transfer function to transfer some balance to an address based on reward scenario. Now the issue i get is, when comparing the balance of the address as well as contract before and after ...
1
vote
1answer
124 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 { ...
1
vote
0answers
101 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 == ...
0
votes
3answers
37 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 ...
0
votes
1answer
45 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 ...
0
votes
1answer
34 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} ...
0
votes
0answers
23 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 ? ...
0
votes
1answer
679 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/...
1
vote
1answer
86 views

Flashloan callFunction being called internally

I had a chance to look at this contract. contract Flashloan is DyDxFlashLoan { uint256 public loan; constructor() public payable { (bool success, ) = WETH.call.value(msg.value)("&...
0
votes
1answer
167 views

Different compiler versions in OpenZepplinn ERC721 folder

We have created a contract by inheriting ERC721Burnable, Ownable contract from openzepplin. The compiler version we are using in our smart contract is 0.6.0. I flattened the smart-contract by using ...
1
vote
1answer
135 views

How to get require() error message?

I can see the error message on Etherscan. But I can't find it in getTransactionRecept(). Is there any special settings that I need set in my Genesis.json before I can see it?
0
votes
1answer
56 views

Is it true that we can't make multiple Transfer() to the same address within a single transaction now?

The code below is for illustrative purposes only. Not the actual production code. function payCommission(address[] payee) public payable { for (uint i = 0; i < payee.length; i++) payee[...
0
votes
2answers
22 views

Couldn't understand the logic behind code for mulitdeed payout contract

While searching on the web I came across this page the user has created multiple examples of solidity smart contract On multiple payout deed smart contract I can't understand this line duePayouts = ...
0
votes
0answers
64 views

Polymorphism in Solidity

I understand that Solidity supports contract polymorphism, but what pattern would one use to create abstract data types for use in derived contracts? Motivating example: Say I have an abstract Storage ...
1
vote
1answer
21 views

Compilation Eror: One contract accessing the variable of another contract

I am trying to compile two contracts. I am getting 'balance' variable error in "HoneyPotCollect.sol" contract. Is balance not a global contract variable? Somebody please guide me how to ...
0
votes
0answers
68 views

Truffle + Infura Mainnet deploy. Transactions never get mined, timing out after 750 seconds

The contract deploys on Rinkeby without a hitch, but when it comes to mainnet it is erroring out strangely. Infura's HTTP endpoint was giving me Invalid JSON RPC RESPONSE "", so I decided to ...
0
votes
1answer
141 views

Why solidity doesn't use “ Null ” and “undefined”?

Like Python or any other language why does Solidity avoid having the Null and undefined properties?
1
vote
1answer
35 views

Why does Solidity not use the years keyword?

Solidity has keywords like seconds, minutes, hours, days and weeks that are used to specify units of time. Why do they not have years?
-2
votes
1answer
44 views

How to make my contract balance as private in Ethereum?

Suppose there are two contracts, A and B. Obviously, balance of A is public and B can read it with address_of_A.balance. Is there a way to make balance of A as a private data and B can't read it with ...
1
vote
1answer
483 views

Data location can only be specified for array, struct or mapping types, but “memory” was given

I am new to solidity. I was trying to compile the following code in chrome browser with Remix. I am getting the following error "Data location can only be specified for array, struct or mapping types, ...
0
votes
2answers
52 views

Problem: Payment between smart contracts without reducing the balance of the sender contract

I work on Truffle. I have two smart contracts A and B. Codes of them are same. A should transfer some ether to B and store some information about this payment. I funded A with METAMASK. But, whenever ...
0
votes
1answer
66 views

delegatecall method - calling context is not being set

We have an issue with delegatecall method. We want to call contract C2 from C1 (which is supposed to be a pass through contract for the user wallet). When we are calling C2 via C1 even using ...
1
vote
1answer
49 views

Receiving error while getting state variable value after using selfdestruct method “Error: Returned values aren't valid, did it run Out of Gas?”

I am using selfdestruct method and passing the payable address to it but receiving the following error when trying to get the value of a state variable : "Error: Returned values aren't valid, did it ...
0
votes
0answers
56 views

Transaction halted with a RUNTIME ERROR

while debugging I encountered this error: There was no revert message. This may be due to an in intentional halting expression, such as assert(), revert(), or require(), or could be due to an ...
1
vote
2answers
39 views

When i call a function: Error: Returned error: VM Exception while processing transaction: invalid opcode

I work on Truffle. My contract is A and its function is infoRep(). infoRep() returns some data. Whenever i call the function in Truffle console the below error occurs: Error: Returned error: VM ...
0
votes
1answer
76 views

Delete mapping within a mapping

I have a mapping with the following structure: mapping(uint256 => mapping(address => SOME_STRUCT)) public submissions; delete submissions[uint256] is not allowed(compiler error). delete ...
1
vote
1answer
47 views

Explicit declaration, the “var” keyword is not allowed syntax error

While trying to compile this contract I'm getting a syntax error complaining about the "var" keyword being disallowed. How do I fix this? pragma solidity ^0.5.0; contract Courses { struct ...
0
votes
1answer
354 views

Openzeppelin Crowdsale

Ok so Ive found Openzeppelin a slightly easier Code to use, it explains better than Solidity does. But now my problem is the Math bit. Im no mathematician neither and cannot get my head around how it ...
0
votes
1answer
69 views

Contract inheritance to share same storage in Proxy pattern for upgradeability

Please bear with me here, I have been trying to figure it out myself but couldn't. I am trying to learn upgradeability with a Proxy pattern .https://blog.gnosis.pm/solidity-delegateproxy-contracts-...