New answers tagged

0

Well, it's always costly when you want to perform the delete operation on an array in solidity. But I found a little bit more efficient manner to resolve this problem. pragma solidity >=0.5.0 <0.7.0; contract deletefromarray{ uint[] array; mapping(uint=>uint) indexOfValue; function removeWithoutGap(uint _valueToDelete) public { uint index = ...


0

Is it possible to return a dynamic array of strings ( string[] ) from a Solidity function? Yes, you can serialize it to bytes and deserialize it back to string[]. In your smart contract: function toBytes(string[] strArray) private pure returns(bytes serialized) { uint startindex = 0; uint endindex = strArray.length - 1; require(endindex >= ...


0

Well, in function acceptChallenge, everything is inside an if clause. The simple conclusion is that the condition in the if statement is always false. Looking at it, I suspect that you're expecting those 24 seconds to elapse "on their own". This is not the case in Ganache, since there are no other participants but yourself. So as long as you don't submit ...


0

You can copy element by element function restart() public returns (uint256[] ) { uint256[] memory result = new uint256[](5); result[0] = 10; uint256[] memory result1 = new uint256[](5); for (uint i=0; i < 5; i += 1) { result1[i] = result[i]; } result1[1] = 20; return result; }


0

Well what you are doing is so strange for me. i think if you want to do this you can take out the result variable from the function memory and put it outside the function in storage. uint256[] public result = new uint256[](5); function restart() public returns (uint256[] ) { result[0] = 10; uint256[] memory result1 = new uint256[](5); ...


Top 50 recent answers are included