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
6
votes
1answer
104 views

Public variable getter shows as transaction in Remix

As of Solidity 0.6.0+ compiler, my remix shows getter functions, built by public variables, as transactions and, therefore, do not return the value. I searched the solidity 0.6.0 breaking changes but ...
5
votes
1answer
1k views

Solidity Vs Vyper

What is the key differences between Solidity and Vyper? In present and future which one can more acceptable for making smart contracts and why?
4
votes
1answer
132 views

Is pre 0.5.0 keccak256(a,b) equivalent to post 0.5.0 keccak256(abi.encodePacked(a,b))?

In pre 0.5.0 Solidity if you wanted to hash a some set of data you would do keccak(a, b, c). Post 0.5.0 keccak only takes 1 arg and it is suggested to use keccak(abi.encodePacked(a,b,c)) instead But ...
3
votes
2answers
1k views

Avoid using “now”

I am using "now" to save the block timestamp details. But there is a warning to avoid its usage. If we need to avoid it what is the best alternative to it.
3
votes
1answer
56 views

Why solidity's keccak returns different value from online generators?

I try to implement my own little modifited commit&reveal voting. I have problem with revael phase. Reveal metod signature look like: function reveal(bytes32[] memory _reveals, bytes32[] memory ...
3
votes
1answer
832 views

Explicit type conversion not allowed from “bytes1” to “uint256”

Just tried to convert byte to uint using Solidity 0.5.x: uint length = uint(arr[i]); and got: MyCode.sol:88:29: TypeError: Explicit type conversion not allowed from "bytes1" to "uint256". ...
3
votes
1answer
838 views

Timeout exceeded during the transaction confirmation process

I am trying to figure out the right syntax for solc 0.5.7 and web3 1 beta 52 Follow my source code: contract.sol pragma solidity ^0.5; contract Hello { string public message; constructor (...
2
votes
1answer
443 views

Update Solidity - 0.5.4 (ERC20 + ERC677)

I'm trying to create an ERC20 Token that can send Tokens to a Receiver Contract similar to how ERC223 does and i decided to try ERC677 but i can't understand how to update this code to match Solidity ...
2
votes
1answer
119 views

How to get access to the storage mapping through the solidity assembler?

referencing the question How to get access to the storage array through the solidity assembler? I have been trying to figure out how to access the mapping (or variable y from the question). The ...
2
votes
2answers
56 views

Geographic location in Solidity

Does solidity have a way of fetching a persons geographic location(using something like msg.sender)? Im building a dApp for national elections, and would need to verify the geographic location before ...
2
votes
1answer
49 views

What is meaning of “address: equivalent to uint160, except for the assumed interpretation and language typing.”?

I'm reading solidity document and cannot understand the meaning of "address: equivalent to uint160, except for the assumed interpretation and language typing." in the doc Does anyone know what is the ...
2
votes
1answer
46 views

Memory to memory variables only create reference, but its not working with delete - Solidity 0.5.0

Learning Solidity latest version 0.5.0. And having bit confusion about data location rules. It says that, Assignments from memory to memory only create references. This means that changes to ...
2
votes
0answers
30 views

How Can You Map a Struct Twice With Different Keys?

I have a struct mapped with an address as the key. I want to iterate through all values of that mapping with another key value, in this case a nonce that I generate in the contract. Is this possible? ...
1
vote
1answer
33 views

How to type cast fixed size byte arrays in solc 0.5.x?

In solc 0.4.28 I was able to do: uint foo = 42; bytes28 bar = bytes28(foo); but in 0.5.9 I'm getting the error: TypeError: Explicit type conversion not allowed from "uint256" to "bytes28". ...
1
vote
3answers
133 views

Verify if an input is a hash

What is the best way to verify that a text I received in mu function is a valid hash? In other words, contains a specified length and is composed only by numbers and "a", "b", "c", "d", "e" or "f"?
1
vote
1answer
32 views

Will ERC223 Tokens work after Serenity Update?

Trying to understand what we should expect after External Owned Accounts will be treated as Contracts after second Serenity update will be live. How does it influence ERC223 Tokens, will they break ...
1
vote
1answer
416 views

Using address.call.value to send ether from contract to contract in 0.5.0 and above

In Solidity v0.4.24 and below, I would send ether from contract to contract using the following code within a bigger function : if (!_address.call.value(_ether)()){ revert(); } ...
1
vote
1answer
47 views

Create Contract Solidity 0.5

My code works with compiler 0.4.25 but not with the latest version. I want to keep track of every "Contract 2" that "Contract 1" create. Contract 1 uint public countContract; address[] public ...
1
vote
1answer
19 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 ...
1
vote
1answer
33 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 ...
1
vote
1answer
42 views

TypeError: Member “editor” not found or not visible after argument-dependent lookup in struct PrivateSmartContract.BuildingRental storage ref

I want to store user's wallet address array as editor's address so i created struct with array like following pragma solidity >=0.4.0 <0.7.0; pragma experimental ABIEncoderV2; contract ...
1
vote
1answer
210 views

Error: Cannot find module 'bignumber.js'

I'm trying to test this smart contract but I can't seem to get the beyond this error, I'm using the latest truffle suite v5.1.16, and web3 v1.2.6. KTokenSale.test.js const BigNumber = web3.BigNumber;...
1
vote
1answer
88 views

How to get web3 to interact with smart contract to input string info

Just cannot get what seems like a simple input from html page to interact with a very simple contract to input data. Started off trying to make this tutorial work: Interacting with a Smart Contract ...
1
vote
2answers
43 views

How can I find out the sender's gas limit?

Is there a way to check Sender's Gas Limit? If the sender sets too low, I will just accept whatever gas amount that he had set and return immediately without hitting the limit. I am trying to ...
1
vote
1answer
24 views

Different behavior of the same contract between JavaScript and Solidity tests with Truffle

I have a simple contract that functions as a ratekeeper - it is constructed with a capacity and time_frame (in blocks) parameters and makes sure we never add more than $capacity payments in any given ...
1
vote
1answer
157 views

What is the unit for the tx.gasprice?

Is it a wei, kwei, mwei, gwei, ... Something else? The API doesn't say much.
1
vote
1answer
20 views

ganache test returns characters instead of numbers

mapping(uint256 => uint256) public amount; function saveAmount(uint256 _id, uint256 _amount) public { amount[_id] = _amount; } I have a function that saves amount in mapping. When I test ...
1
vote
1answer
78 views

Remix error : Function declared as view but this (potentially) modifies state

i'm following a tutorial but now it is old, because was written more then 1 year ago, with 0.4.24 pragma and i also want upgrade this code. I got this error and i'm pretty sure to know why: view and ...
1
vote
1answer
74 views

Encryption in Solidity - and yes of course the plaintext will be visible

I am using Solidity to write an Ethereum smart contract. I have a specific use case that requires a piece of data to be encrypted on the chain, despite the fact that both the plaintext and the ...
1
vote
1answer
124 views

How to pass a document as function argument(upload document)

I am working on a project in solidity where I want to generate a SHA256 hash value for the document. So which means when I pass a file to a function the function should return the hash value. can ...
1
vote
1answer
695 views

Solidity 0.5.2 - OpenZeppelin - New SafeERC20 callOptionalReturn(token,data)

i've been trying to mix ERC20 functionality with ERC223 function overloading technique and create a bridge for backwards compatibility using SafeERC20. For relevancy sake i renamed SafeERC20 into ...
1
vote
2answers
143 views

Code Example from “Mastering Ethereum: Building Smart Contracts and DApps” doesn't work

I'm reading the Ethereum book of Gavin Wood right know and the following code example gives an error message when I try to compile it with truffle: pragma solidity ^0.4.22; contract calledContract { ...
1
vote
1answer
44 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
48 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 == ...
1
vote
1answer
26 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?
1
vote
1answer
36 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 ...
1
vote
1answer
43 views

How to use solidity library with truffle

I'm using truffle V5.1.13 and when I run truffle test the res variable contains a transaction receipt rather than the expected 2. I notice if I remove everything that has to do with the library things ...
1
vote
1answer
40 views

Transaction working in remix but not errored from dapp

I have a master contract which deploys instances of other contracts. pragma solidity ^0.5.0; pragma experimental ABIEncoderV2; contract DataEntityContract { DataEntity DE; constructor(...
1
vote
1answer
206 views

Explicit type conversion not allowed from “bytes32” to “address”

I am using solidity 0.5.0 when i compile code i am throwing exception as Explicit type conversion not allowed from "bytes32" to "address". code is working fine in remix IDE and my code is as ...
1
vote
0answers
41 views

transfer(amount) failed even when it is not a contract

address payable receiver; receiver.transfer(amount); The receiver is NOT an contract, and the amount is only 0.4 ether, the contract is holding sufficient ether in its balance. I understood that ...
1
vote
1answer
213 views

what is 'UnimplementedFeatureError: Not yet implemented - FixedPointType' error?

what is 'UnimplementedFeatureError: Not yet implemented - FixedPointType' error in solidity while compiling through truffle ? How to fix it ? Using solidity compiler version - 0.5.9
1
vote
1answer
76 views

Invalid opcode when trying to pass address as parameter to contract

When I try to pass address as parameter to this addEmployee function it gives me this error: invalid opcode The execution might have thrown. Debug to get more information. modifier onlyOwner(...
1
vote
1answer
42 views

Direct and separate funds into two different payable functions

Basically I have this code where I'm trying to divide a specific amount of ether into two different function calls within the contract. function singleTransaction(arg1) payable { require(msg.value ...
1
vote
1answer
300 views

Error when testing the contract

ApprovalContract.sol pragma solidity ^0.5.1; contract ApprovalContract{ address public sender; address payable public reciever; address public constant approver=...
1
vote
0answers
30 views

How to do loop all the metamask Accounts loop and display data from that address in React frontend + Dapp App JS [duplicate]

I want to Display data stored on the Ropsten Network in more then 2 metamask accounts. I want to display the result on the Home page in the table form. For that I need to loop through each ...
1
vote
1answer
57 views

solidity 0.4.25 to 0.5.0

when I used 0.4.25, it compiles successfully. function callByFun(address addr)returns (bool){ bytes4 methodId = bytes4(keccak256("increaseAge(string,uint256)")); return addr.call(methodId,"...
1
vote
1answer
61 views

Event declaration which fix my tests

I'm going to try to put this in simple. This is the code of my contract: pragma solidity ^0.5.0; contract Lottery { address public manager; address[] public players; event Deposit(...
1
vote
2answers
44 views

Why is solidity throwing “Note: The constructor should be payable if you send value. ”, when clearly the issue is elsewhere?

I'm writing a contract on Remix that is able to deploy and track child contracts. Here are the 2 contracts: pragma solidity ^0.5.0; Contract Factory contract ContractFactory{ ChildContract[] ...
1
vote
1answer
28 views

Use Values Returned from One Function in Another

need a little help if you can spare the time. Making a little card game where people can collect "warrior" cards. We'll have an initial 12 master "cards" that supply the initial traits for the ...
0
votes
3answers
207 views

transferFrom function not working in ICO Smart contract

I am facing issues with the transferFrom function of smart contract address 0x6560a9b6436e129cf835ab9da96201207facd4f8: I copied the smart contract code from etherscan.io and deployed on ropsten ...