Ultimately, advanced and sophisticated smart contracts will be available for Bitcoin. The straightforward inclusion of the Web Desktop with the Bitcoin blockchain, which does away with the need for a reliable middleman or overpass, has been made public by the DFINITY R&D team as a beta release. With the integration’s APIs, devs can actually build …
CRYPTO NEWS
DFINITY R&D Team Announces BTC-ICP Integration Beta Release
Please consider this contract: pragma solidity 0.8.7; contract Test { struct UserStruct { uint256 betAmount; uint256[] potentialWinnings; string teamChosen;} mapping(address => UserStruct[]) public userStructs; function appendUserBet(string memory userTeamChosen,uint256 eventNumber) public payable { UserStruct memory userStruct = UserStruct(msg.value,new uint256[](0),userTeamChosen); userStructs[msg.sender].push(userStruct);} function updatePotentialWinnings(uint256 eventNumber,address userId,uint256[] memory potentialWinnings) public { userStructs[userId][eventNumber].potentialWinnings = potentialWinnings;}} It works fine, however when::Listen
Please consider this contract:
pragma solidity 0.8.7; contract Test { struct UserStruct { uint256 betAmount; uint256[] potentialWinnings; string teamChosen;} mapping(address => UserStruct[]) public userStructs; function appendUserBet(string memory userTeamChosen,uint256 eventNumber) public payable { UserStruct memory userStruct = UserStruct(msg.value,new uint256[](0),userTeamChosen); userStructs[msg.sender].push(userStruct);} function updatePotentialWinnings(uint256 eventNumber,address userId,uint256[] memory potentialWinnings) public { userStructs[userId][eventNumber].potentialWinnings = potentialWinnings;}}
It works fine, however when I’m including a function below to the contract, it doesn’t compile. It errors out with TypeError: Invalid type for argument in function call. Invalid implicit conversion from uint256 to uint256[] memory requested.
function addAllPotentialWinnings(uint256 _eventNumber, uint256[] memory _potentialWinnings, address[] memory _usersList) public { for (uint i =0; i<_usersList.length;i++){ updatePotentialWinnings(_eventNumber,_usersList[i],_potentialWinnings[i]);}}
I want to provide an array of arrays (2D-array of dynamic size) as an argument to the function, but I seem to be doing it incorrectly. From what I was able to understand is that UserStruct
expects potentialWinnings
to be in uint256[]
format, but it recieves them as uint256
. By design I want to provide the function with an array that looks like this: [[0,1,2],[2,5,6],[x,y,z],...]
How do I change my contract such that it "knows" that the array i’m passing as an argument, is going to have the required arrays inside?
Thank you in advance!
Showing 1–8 of 312 results
-
Electroneum ETN Unisex Twill Crypto Hat
USD$25.30 Select options -
Pearl Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Insight Chain INB Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
DASH Unisex Twill Crypto Hat
USD$25.30 Select options -
Naga NGC Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Paypex PAYX Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Poet POE Crypto Coin Unisex Trucker Hat
USD$28.08 Select options -
Cardano ADA Unisex Twill Crypto Hat
USD$25.30 Select options
