4

You are concatenating strings in JavaScript. Here is what happens: var test = "he"; var test2 = "llo"; console.log(test+test2); OUTPUTS: hello. You are using integers as strings. Therefore you need to convert your variables to int before adding them. Here is an example: highestBidAmount = parseInt(highestBidAmount, 10); Sidenote: Don't change the 10 ...


4

This is answered in the Solidity documentation. From https://solidity.readthedocs.io/en/v0.5.11/types.html#modulo: Modulo with zero causes a failing assert.


1

It depends on (1) how you implement the function and (2) how you call it. As a pure function This is how it is defined above. The function will NOT revert, since it doesn't end up executed by all the nodes on the network (state-changing methods end up like that). As a state-changing function Yes, mod 0 does end up in a reverted tx. This is why ...


1

No. The stack is part of the EVM specification and you can't change it. Hope it helps.


1

There is no security issue when making getter functions, period! A getter function is constant (typically view), hence does not change the state. Therefore, such function cannot yield a security breach by definition. You may have a security issue in some non-constant function which calls some getter function, but that security issue will not be resolved ...


1

bool val=owner.send ( reward ); Let's rewrite as bool success = owner.send(reward); Now, it says success is unused. You can go: bool success = owner.send(reward); require(success, "The send failed."); or require(owner.send(reward), "The send failed."); or owner.transfer(reward); // reverts on fail or, if this blog freaks you out (hat tip to Steve) ...


1

Yes, it depends on the number of members in the enum. See the official documentation: pragma solidity >=0.4.16 <0.6.0; contract test { enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill } ActionChoices choice; ActionChoices constant defaultChoice = ActionChoices.GoStraight; function setGoStraight() public { choice = ...


1

First convert int_const to uint265 then convert to bytes32. diff = bytes32 (uint256(11111)); and there is another problem with your contract. You are using msg.sender and msg.value in your constructor. For that you need to mark your constructor as payable. constructor() payable public


1

It reverts, but with INVALID opcode (similar to assert) rather than REVERT opcode (similar to require). In order to impose the latter, you can add require(b != 0) prior to return a % b. If b is a user-input value, then you should add this require statement. If b is an internally-generated value in your system and you know that it is never supposed to be 0,...


1

It's a bit funny that the Solidity documentation hints about such a function abs (https://solidity.readthedocs.io/en/v0.5.3/types.html) but I can't get it to compile at least in Remix. So I assume there is no such function and the documentation is just a bit off (wouldn't be the first time). There are probably some libraries which contain that functionality ...


1

Just for informative use around the question asked: you can create two smart-contracts. one that stores the data and another that has the elements that need to be stored. Each time the second contract is deployed, the constructor parameters can be saved in the first contract. First Contract pragma solidity ^0.4.17; contract StorageContract{ struct ...


1

You declared you function as async but never used the async/await pattern. I added the await at the correct position for you. Try this: export const loadExchange = async (web3, networkId, dispatch) => { try { const exchange = await web3.eth.Contract(Exchange.abi, Exchange.networks[networkId].address) dispatch(await exchangeLoaded(exchange)) ...


1

well, given that all the members of your struct are of the same type, string, one way to do it would be to use an enum and an array of strings: enum fields {idNo, date, code, docCode, vendorNumber, invoiceDate, typeOfTransaction} struct lineItem { string[8] data; } then you can do function getByInternalDocNo(string memory creator,string memory docNo, ...


1

It looks like you have two bugs. First: bytes4 sig = bytes4(keccak256("verifyHash(string)")); The actual function takes a bytes32, not a string, so this should be: bytes4 sig = bytes4(keccak256("verifyHash(bytes32)")); Second: 0x20, // Inputs are 32 bytes long The input is actually 36 bytes long. 4 bytes for the function selector, and then a single ...


1

The unit is wei. Wei is the lowest possible denomination that can be handled by Solidity. Because of this, various values can be calculated (but not necessarily the other way around), such as ether, tx.gasprice, and even ERC20 tokens with arbitrary decimals.


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