Hot answers tagged

13

It states in the v0.5 breaking changes list that: Explicit data location for all variables of struct, array or mapping types is now mandatory. This is also applied to function parameters and return variables. The docs are implicit in stating that strings and bytes are included - as they are array implementations, rather than an error in the compiler.


13

From this: pragma solidity^0.5.0; contract Contract { string public name; function Contracts(string passedName) public { name = passedName; } function setName(string newName) public { name = newName; } } To This: pragma solidity^0.5.0; contract Contract { string public name; function Contracts(string ...


12

As of Solidity 0.5.0. https://solidity.readthedocs.io/en/v0.5.0/050-breaking-changes.html Explicit data location for all variables of struct, array or mapping types is now mandatory. This is also applied to function parameters and return variables. For example, change uint[] x = m_x to uint[] storage x = m_x, and function f(uint[][] x) to function f(uint[...


7

The reason it is not being read is because this version of Metamask enables privacy mode by default. What this does is require you to approve the application to view/use your wallets on Metamask. For your specific issue, you have not yet approved Remix to use your accounts, therefore it cannot read your addresses, as you are seeing. To fix this, enable ...


6

You can combine these two values into one hash like this then use it as the mapping key: keccak256(<contractAddress>, <nftID>) Another option is to have mappings of mappings. So: mapping(address => mapping(uint => myStateData))


6

I got help from Veniamin. I had error "Error: Couldn't decode from ABI: 0x." when call get request with wrong contract address I made a mistake... I was using 'account address', instead of 'contract address'! The code works, once correct 'contract address' was used.


6

I fixed the similar error by deleting .json files from build/contracts folder and then running truffle migrate in the terminal. However, the error occurred in Visual Studio Code, not Remix IDE. It appeared after running truffle migrate --reset.


6

Guys I really hate my life. It took me over 10 hours to find the solution to this problem. I compiled the contract with various different methods. Deployment worked with each of the but the contract couldn't be verified nontheless. After a while I figured out that I didn't set the optimisation checkbox on etherscan to "yes". I was compiling optimized all ...


5

For debugging transaction you can use traceTransaction debugging method that will attempt to run transaction as it was executed in the network. You can get more details from this official documentation: https://github.com/ethereum/go-ethereum/wiki/Management-APIs#debug_tracetransaction


5

I deployed the contract on the Kovan test net. Deployment versions same as you. Everything worked properly. I see no reason for it not to work on Ropsten. How did you deploy the contract? Maybe share the address to I can try to verify it.


4

I've upgraded a part of codes from @Richard Horrocks. First, just copy to clipboard this 'localStorage' > copy(localStorage); You can check beautifully json codes. and if you restore your sol files, you can this after pasting localStorage code to input objRemix variable. var objRemix = {} Object.keys(objRemix).forEach(function (k) { localStorage....


4

The opcodes that exist to call into a contract (call, delegatecall, staticall) take no parameter to jump to a location in the bytecode. All of these calls will begin execution at the very beginning of the bytecode and there is no way to alter this.


4

It seems like you treated "315f6b6f74000000000000000000000000000000000000000000000000000000" like a string instead of the hexadecimal byte sequence it actually is. Via web3 0.2.x: web3.sha3('315f6b6f74000000000000000000000000000000000000000000000000000000') > "0x90a0076f07f9884805bdc4d668c55756ff42238a0ad7b824b8a267783e822544" web3.sha3('...


4

This seems to be working. But you can test it out on your own with your specific use-case in remix.


4

You need to choose the right compiler version. On the right sidebar you can see your current compiler version. The compiler version must match the number used in the pragma solidity! Expand the dropdown and choose 0.5.12 nightly. You should probably downgrade to a full commit version like 0.5.11 commit. I hope this helps!


3

web3 also has a function to estimate the gas needed, you could do something like: var gasEstimate = web3.eth.estimateGas({data: bytecode}); var contract = web3.eth.contract(abi); var instance = contract.new({data: bytecode, from: from, gas: gasEstimate}); var receipt = web3.eth.getTransactionReceipt(instance.transactionHash);


3

The type of check you are performing is not only useless but it's plain wrong. When a user issues a transaction with 90 Ethers as value, the 90 Ethers (plus gas) is immediately deducted from the account. The 90 Ethers becomes then visible in address(this).balance. Therefore, also, the sender's balance is also updated and can be seen with address(msg.sender)....


3

I know you have got the right answer, however just posting it with the code snippet that execute fine, after adding memory keyword - with solidity version 0.5.1: It is both setter and getter pragma solidity '0.5.1'; contract MyFirstContract { uint productid; string public productname; function setname (string memory name1) public { ...


3

Make sure contractAddress is of type address payable. And yes, you'll need to provide an argument. E.g.: address payable contractAddress = ...; contractAddress.call.value(1 ether).gas(53000)("");


3

Check @goodvibration answer. It should work in most instances. I don't recommend the answer that I will share below, it will ignore the EIP-170, hopefully there is a better answer I was only able to make it migrate using: ganache-cli --gasLimit=0x1fffffffffffff --allowUnlimitedContractSize -e 1000000000 --allowUnlimitedContractSize: "Allows unlimited ...


3

Someone might have a better idea, but you could serve Remix locally on your own machine by following the instructions for building here and here. Once you've understood the build flow, you can then tweak the runs value in the compiler-input.js file: module.exports = (sources, opts) => { return JSON.stringify({ language: 'Solidity', sources: ...


3

You don't need to put any name after constructor. Just write it as : constructor (address _owner) payable public Also change your pragma to: pragma solidity ^0.5.0; for better results.


3

Remove parentheses of g function from funcMap[1] = g(); and set funcMap[1] = g;. look this code run without error: pragma solidity ^0.5.2; contract b { mapping(uint => function()) funcMap; function g() public pure { uint x=0; } function update() public { funcMap[1] = g; } }


3

Array userAddresses stored multiple addresses in it. So you can not call send or transfer method with multiple addresses at a time so you have to call like this : userAddresses[i].transfer(value);. So your code should be like this: pragma solidity ^0.4.16; contract init { address[] public userAddresses; function addStudent(address _user) ...


3

So how this Gas estimation work as i read that reading data in blockchain is free, so if its free how that Gas usage is paid by the function "totalInvestorInvestment" and "totalLoans"? It's net free because read-only ops can't update the chain state. Gas is still subject to accounting and limits. Further, if a read-only function is called in the context of ...


3

This particular code can't do that because <address>.transfer() only makes 2300 gas available to the recipient, which is not enough to make another ether transfer. This could be made to work by providing more gas with the ether transfers, e.g. address(c).call.gas(50000)(""). This forwards 50,000 gas, which should be more than enough to make the ...


3

Sincerely this cannot be a major item if you design your code in a structured way. It seems probable that you use a different sw design paradigm from that for which REMIX has been designed. In that paradigm, the ABI should change very rarely because it specifies the external interface surface of the code. If not, it could means that you change your system ...


3

You need to use constructor() to define constructor. Replace function Ballot() public with constructor() public Pass index of array whose value you want in return. Do the iteration on application side and not in smart contract. Replace function getCount() public view returns (uint[8]) { return proposals; } with function getCount(uint ...


3

You misunderstand inheritance. In this arrangement, the source code of firstContract.sol is rolled up and included in secondContract.sol. You deploy secondContract. The end. Communication with another deployed contract is a separate concept that would not include is DeployedContract. Have a look at this for a concise example of how that would work in ...


3

Change your error statement to this : bstr[k--] = byte(uint8(48 + i % 10)); It will work because of same bit length of both types.


Only top voted, non community-wiki answers of a minimum length are eligible