Syntax Error with 'if'Error: “message”:“function ”Ballot“ arguments must include ”proposalNames“”}Parse an Integer to a String in Solidity?This contract does not implement all functions and thus cannot be createdPassing the address of a structure allocated in storage on one contract, to a function on another contractA function declared payable is throwing a VMerror:revert in RemixHow is gas adjusted for a transfer in solidity?remix ERC223: This contract does not implement all functions and thus cannot be createdDeploy Contract Syntax ErrorLoad another deployed contract's public valuescall: Warning: Unused local variable
Does image quality of the lens affect "focus and recompose" technique?
Links to webpages in books
The use of "I" and "we" used in the same sentence and other questions
Inverse-quotes-quine
Can a US President have someone sent to prison?
What is the line crossing the Pacific Ocean that is shown on maps?
Is there a maximum distance from a planet that a moon can orbit?
What would Earth look like at night in medieval times?
Why does Darth Sidious need bodyguards?
Fitting a mixture of two normal distributions for a data set?
Simple object validator with a new API
Architecture of networked game engine
Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?
What determines the "strength of impact" of a falling object on the ground, momentum or energy?
Averting Real Women Don’t Wear Dresses
Singing along to guitar chords (harmony)
Why do some games show lights shine through walls?
Should I hide continue button until tasks are completed?
Find smallest index that is identical to the value in an array
Is it OK to bottle condition using previously contaminated bottles?
How should I behave to assure my friends that I am not after their money?
How often can a PC check with passive perception during a combat turn?
Was touching your nose a greeting in second millenium Mesopotamia?
Why aren't (poly-)cotton tents more popular?
Syntax Error with 'if'
Error: “message”:“function ”Ballot“ arguments must include ”proposalNames“”}Parse an Integer to a String in Solidity?This contract does not implement all functions and thus cannot be createdPassing the address of a structure allocated in storage on one contract, to a function on another contractA function declared payable is throwing a VMerror:revert in RemixHow is gas adjusted for a transfer in solidity?remix ERC223: This contract does not implement all functions and thus cannot be createdDeploy Contract Syntax ErrorLoad another deployed contract's public valuescall: Warning: Unused local variable
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to compile the following program:
pragma solidity ^0.5.1;
contract MKotET1_1
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function( ) external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
if(!king.call.value(compensation)("")) revert();
king = msg.sender;
I am getting following syntax errors:
solc MKotET_stackExchange.sol
MKotET_stackExchange.sol:12:14: Error: Unary operator ! cannot be applied to >type tuple(bool,bytes memory)
if(!king.call.value(compensation)("")) revert();
^--------------------------------^ MKotET_stackExchange.sol:12:14: Error: Type tuple(bool,bytes memory)
is not implicitly convertible to expected type bool.
if(!king.call.value(compensation)("")) revert();
^--------------------------------^
Somebody please guide me how to remove the above syntax errors.
Zulfi.
solidity contract-development transactions contract-design error
add a comment |
I am trying to compile the following program:
pragma solidity ^0.5.1;
contract MKotET1_1
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function( ) external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
if(!king.call.value(compensation)("")) revert();
king = msg.sender;
I am getting following syntax errors:
solc MKotET_stackExchange.sol
MKotET_stackExchange.sol:12:14: Error: Unary operator ! cannot be applied to >type tuple(bool,bytes memory)
if(!king.call.value(compensation)("")) revert();
^--------------------------------^ MKotET_stackExchange.sol:12:14: Error: Type tuple(bool,bytes memory)
is not implicitly convertible to expected type bool.
if(!king.call.value(compensation)("")) revert();
^--------------------------------^
Somebody please guide me how to remove the above syntax errors.
Zulfi.
solidity contract-development transactions contract-design error
Use require, revert() ist deprecated I think, that is not an answer
– Majd TL
8 hours ago
add a comment |
I am trying to compile the following program:
pragma solidity ^0.5.1;
contract MKotET1_1
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function( ) external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
if(!king.call.value(compensation)("")) revert();
king = msg.sender;
I am getting following syntax errors:
solc MKotET_stackExchange.sol
MKotET_stackExchange.sol:12:14: Error: Unary operator ! cannot be applied to >type tuple(bool,bytes memory)
if(!king.call.value(compensation)("")) revert();
^--------------------------------^ MKotET_stackExchange.sol:12:14: Error: Type tuple(bool,bytes memory)
is not implicitly convertible to expected type bool.
if(!king.call.value(compensation)("")) revert();
^--------------------------------^
Somebody please guide me how to remove the above syntax errors.
Zulfi.
solidity contract-development transactions contract-design error
I am trying to compile the following program:
pragma solidity ^0.5.1;
contract MKotET1_1
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function( ) external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
if(!king.call.value(compensation)("")) revert();
king = msg.sender;
I am getting following syntax errors:
solc MKotET_stackExchange.sol
MKotET_stackExchange.sol:12:14: Error: Unary operator ! cannot be applied to >type tuple(bool,bytes memory)
if(!king.call.value(compensation)("")) revert();
^--------------------------------^ MKotET_stackExchange.sol:12:14: Error: Type tuple(bool,bytes memory)
is not implicitly convertible to expected type bool.
if(!king.call.value(compensation)("")) revert();
^--------------------------------^
Somebody please guide me how to remove the above syntax errors.
Zulfi.
solidity contract-development transactions contract-design error
solidity contract-development transactions contract-design error
edited 8 hours ago


shane
2,8024 gold badges9 silver badges32 bronze badges
2,8024 gold badges9 silver badges32 bronze badges
asked 8 hours ago
zak100zak100
1107 bronze badges
1107 bronze badges
Use require, revert() ist deprecated I think, that is not an answer
– Majd TL
8 hours ago
add a comment |
Use require, revert() ist deprecated I think, that is not an answer
– Majd TL
8 hours ago
Use require, revert() ist deprecated I think, that is not an answer
– Majd TL
8 hours ago
Use require, revert() ist deprecated I think, that is not an answer
– Majd TL
8 hours ago
add a comment |
2 Answers
2
active
oldest
votes
Try with this:
pragma solidity ^0.5.1;
contract MKotET1_12
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function() external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
(bool success, ) = king.call.value(compensation)("");
require(success);
king = msg.sender;
From docs:
In order to interface with contracts that do not adhere to the ABI, or
to get more direct control over the encoding, the functionscall
,
delegatecall
andstaticcall
are provided. They all take a single
bytes memory
parameter and return the success condition (as abool
)
and the returned data (bytes memory
).
add a comment |
You are getting a reversion because a call
returns two values and you are treating it as one.
When performing king.call.value(compensation)("")
, what you actually receive back is the success bool and the bytes response. As it stands, you are trying to check for the bool value, but ignoring the fact that it also returns a response. Your code should look as follows:
(bool success, bytes memory response) = king.call.value(compensation)("")
require(success);
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "642"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f72125%2fsyntax-error-with-if%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try with this:
pragma solidity ^0.5.1;
contract MKotET1_12
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function() external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
(bool success, ) = king.call.value(compensation)("");
require(success);
king = msg.sender;
From docs:
In order to interface with contracts that do not adhere to the ABI, or
to get more direct control over the encoding, the functionscall
,
delegatecall
andstaticcall
are provided. They all take a single
bytes memory
parameter and return the success condition (as abool
)
and the returned data (bytes memory
).
add a comment |
Try with this:
pragma solidity ^0.5.1;
contract MKotET1_12
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function() external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
(bool success, ) = king.call.value(compensation)("");
require(success);
king = msg.sender;
From docs:
In order to interface with contracts that do not adhere to the ABI, or
to get more direct control over the encoding, the functionscall
,
delegatecall
andstaticcall
are provided. They all take a single
bytes memory
parameter and return the success condition (as abool
)
and the returned data (bytes memory
).
add a comment |
Try with this:
pragma solidity ^0.5.1;
contract MKotET1_12
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function() external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
(bool success, ) = king.call.value(compensation)("");
require(success);
king = msg.sender;
From docs:
In order to interface with contracts that do not adhere to the ABI, or
to get more direct control over the encoding, the functionscall
,
delegatecall
andstaticcall
are provided. They all take a single
bytes memory
parameter and return the success condition (as abool
)
and the returned data (bytes memory
).
Try with this:
pragma solidity ^0.5.1;
contract MKotET1_12
address payable king; uint public claimPrice = 100;
function calculateCompensation() public returns(uint)
function() external payable
if (msg.value < claimPrice) revert();
uint compensation = calculateCompensation();
(bool success, ) = king.call.value(compensation)("");
require(success);
king = msg.sender;
From docs:
In order to interface with contracts that do not adhere to the ABI, or
to get more direct control over the encoding, the functionscall
,
delegatecall
andstaticcall
are provided. They all take a single
bytes memory
parameter and return the success condition (as abool
)
and the returned data (bytes memory
).
answered 8 hours ago
albertoalberto
4632 silver badges7 bronze badges
4632 silver badges7 bronze badges
add a comment |
add a comment |
You are getting a reversion because a call
returns two values and you are treating it as one.
When performing king.call.value(compensation)("")
, what you actually receive back is the success bool and the bytes response. As it stands, you are trying to check for the bool value, but ignoring the fact that it also returns a response. Your code should look as follows:
(bool success, bytes memory response) = king.call.value(compensation)("")
require(success);
add a comment |
You are getting a reversion because a call
returns two values and you are treating it as one.
When performing king.call.value(compensation)("")
, what you actually receive back is the success bool and the bytes response. As it stands, you are trying to check for the bool value, but ignoring the fact that it also returns a response. Your code should look as follows:
(bool success, bytes memory response) = king.call.value(compensation)("")
require(success);
add a comment |
You are getting a reversion because a call
returns two values and you are treating it as one.
When performing king.call.value(compensation)("")
, what you actually receive back is the success bool and the bytes response. As it stands, you are trying to check for the bool value, but ignoring the fact that it also returns a response. Your code should look as follows:
(bool success, bytes memory response) = king.call.value(compensation)("")
require(success);
You are getting a reversion because a call
returns two values and you are treating it as one.
When performing king.call.value(compensation)("")
, what you actually receive back is the success bool and the bytes response. As it stands, you are trying to check for the bool value, but ignoring the fact that it also returns a response. Your code should look as follows:
(bool success, bytes memory response) = king.call.value(compensation)("")
require(success);
answered 8 hours ago


shaneshane
2,8024 gold badges9 silver badges32 bronze badges
2,8024 gold badges9 silver badges32 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Ethereum Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fethereum.stackexchange.com%2fquestions%2f72125%2fsyntax-error-with-if%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use require, revert() ist deprecated I think, that is not an answer
– Majd TL
8 hours ago