Hot answers tagged

2

Your answer to my comment seems to indicate that the new UI of Remix now adds some right-padding. Padding left yourself is a good solution for manual testing. When you get to build a Dapp, be very careful about sanitizing inputs.


2

You should not specify the types of parameters when you pass them in a function-call: users[userID] = kullanicilar(string name, string surname, age); Change it to: users[userID] = kullanicilar(name, surname, age);


2

When you use the call function, you can control the returned success condition as a bool and check if the call succeed or not. function approveAndCall(address payable _spender, uint256 _value, bytes memory _data) public payable returns (bool) { require(_spender != address(this)); this.approve(_spender, _value); (bool success, ) = ...


2

Update: I am able to deploy my contract using solidity ^0.5.0 but higher versions does not work. Is your private network using the Constantinople EVM? If you can deploy 0.5.0 but not 0.5.7, you might be on Byzantium. In Remix, on the compiler tab, try changing the EVM version from "compiler default" to "Byzantium" and see if you're able to deploy ...


2

According to the documentation, it’s web3.eth.sign(data, address). I think you inversed the parameters. See https://web3js.readthedocs.io/en/1.0/web3-eth.html#sign. Also, do you send the good hash in the call_ecover function? I think you need to send the hash of msg (in your case, a hash of a hash: web3.sha3(msg)).


1

It is not posible for all cases unless totalA equals totalB in which case you will have amountB = amountA. The division truncates the result discarding decimals digits, in your example the return value of convertBtoA should be 163813609331349736.27117520077928403. For most use cases small rounding errors are accepted, for example ERC20 and Ether both have ...


1

You didn't explain the periodicity and other details. Is the membership fixed or do they come and go? Does the contract continue to gain/lose on operations, or is this a wrap-up and final settlement? In the simplest case I can think of, all members join (deposit), then things happen, then you establish the entitlement of each member at a point in time and ...


1

pragma solidity ^0.5.0; contract Product { Factory public factory; Product public x; constructor(Product _reference, Factory _factory) public{ x = _reference; factory = _factory; } function haveFactoryCreateProductWithReferenceToThis() public { emit ProductCreated(factory.createNewProduct(this)); } event ProductCreated(Product indexed ...


1

In Remix, there's a problem with blockhash() when using Javascript VM (https://github.com/ethereum/remix-ide/issues/1794). If you try to deploy this contract in Ropsten, it will not fail. So, the problem lies in line 375, which runs when the constructor is called. challengeNumber = block.blockhash(block.number-1);


1

This is what I thought, Maybe when you compile the contract, the compiler not compiling the changes of your contract. That's why the contracts on remix and etherscan is different. And it looks like the deployed bytecode it similiar with other contracts, that's why the code tab is already verified. I try to redeploy your contract and succesfully verified the ...


1

The following code snippet works: //pragma solidity ^0.5.0 function checkSignature(bytes32 h, uint8 v, bytes32 r, bytes32 s) public pure returns (address signer) { bytes memory prefix = "\x19Ethereum Signed Message:\n32"; bytes32 prefixedHash = keccak256(abi.encodePacked(prefix,h)); signer = ecrecover(prefixedHash, v, r,...


1

First you need the reference of the book and then you can get one chapters by passing the index of it (uint256 chapter). Try with this: pragma solidity ^0.5.0; contract NewBook { struct ChapterData { // string chapterID; string title; string color; uint pages; } struct BookData { // string bookID; ...


1

I think it’s a node-gyp package issue. Here are some commands to try to install this package. If you use windows try : npm install --global --production windows-build-tools node-gyp configure --msvs_version=2015 npm config set python /path/to/executable/python2.7 And for Ubuntu/Mac users, try : sudo apt install build-essential sudo npm install -g node-...


1

It seems that Remix does this automatically. Library code: pragma solidity ^0.5.10; library Foo { struct F { uint256 x; } function foo (F storage f) external { f.x = 123456789; } } Main contract code: pragma solidity ^0.5.10; import './Foo.sol'; contract Bar { Foo.F public f; function bar () public { ...


1

Your function takes an array of structures as an argument:


1

It is not possible to automatically format/beautify the code at this time. However, Remix is open source and has modules that anyone can add. If you want, you are able to create an uncompromising code formatter, like Black for Python, that can be used as a Remix module.


1

Answer by Rob Hitchens - B9lab worked! I did face an error due to difference in version.In case you are using solidity version > 0.5.0, some changes that were required: pragma solidity ^0.5.0; contract HelloWorld { string saySomething; constructor() public { saySomething = "Hello World!"; } function speak() public view returns(...


1

As the code says, you need to insert your address here (without "<>"). I've used one of Remix: // Add your wallet address here which will contain your total token supply treasury = address(0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c);


1

The code you posted looks similar to an ERC20 token transfer, not an ether transfer. These two types of transfers are handled differently in solidity. To transfer ETH, you need to use the send() transfer() function (see smarx's comment for strikethrough clarification). When using this function, the appropriate amount of ETH must already live in the contract ...


1

This "warning" relates to the 'require' conditions that may not be 'true'. It can be safely ignored. Experiment with 'require' in a simple setting to see what I mean. Hopefully the Remix team will find a way to make the warning more useful, with fewer false positives. Hope it helps. P.s. You can silence the high/infinite gas warning in Remix.


1

You will see the same warning in Remix if you look at the compiler page. The warning is quite clear: you have a variable which is not used anywhere in the function logic. It's not an error but the compiler is trying to help you to save gas and to make the function cleaner by removing the unneeded parameter. If you want you can just ignore the warning. ...


1

Use a mapping like: mapping(address => user) public users Each address will have a user. You can improve that if you use msg.sender instead of address (function parameter), because you don't need to provide the address, and each user can change his data and see it (you need to remove the onlyOwner modifier in that case). pragma solidity >=0.4.0 <...


1

As mentioned by @goodvibration, you do not need to specify the types of the struct members when you declare a new struct "instance" ( new struct instance = new variable of type struct). Because the type is already specified in your initial struct definition This is why the compiler returns an error message : Basically, the Solidity compiler expects a ...


1

heyyy I found my answer guys :) thanks for the contribution the answer is just chance the mapping and forget the getUser function. code is : pragma solidity >=0.4.0 <0.7.0; contract NewHello{ struct user{ string name; string surname; uint age; } event infoChanged( string name, string surname, uint age ); uint newUser; ...


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