what is the meaning of 0x0? say when variable gets assigned to it, example: keccak256(number) = 0x0;Using the “Publish” button of Solidity Online CompilerNot able to read Array of Addresses in FunctionWhat is uint256?What does “0x0 Transaction mined but execution failed” mean when attempting to deploy via Remix on Rinkeby?What is the keccak256 reference in opcodes from solc?What is the meaning of “Expressions that might have a side-effect on memory allocation are allowed”?Why do people hash the address?Why send ether to 0x0 if user accidentally sends to contract?how to hash an array of address?Transaction reverted during contract execution [Reverted]
Was Luke Skywalker the leader of the Rebel forces on Hoth?
Makefile strange variable substitution
In the quantum hamiltonian, why does kinetic energy turn into an operator while potential doesn't?
How many characters using PHB rules does it take to be able to have access to any PHB spell at the start of an adventuring day?
Meaning of ちはース as an exclamation
They call me Inspector Morse
Do f-stop and exposure time perfectly cancel?
Is "history" a male-biased word ("his+story")?
Counting all the hearts
Do I really need to have a scientific explanation for my premise?
Why was Goose renamed from Chewie for the Captain Marvel film?
Reversed Sudoku
How did Alan Turing break the enigma code using the hint given by the lady in the bar?
Difference on montgomery curve equation between EFD and RFC7748
PTIJ: Should I kill my computer after installing software?
Why the color red for the Republican Party
Could you please stop shuffling the deck and play already?
Hotkey (or other quick way) to insert a keyframe for only one component of a vector-valued property?
What are actual Tesla M60 models used by AWS?
Vocabulary for giving just numbers, not a full answer
What problems would a superhuman have whose skin is constantly hot?
Can Mathematica be used to create an Artistic 3D extrusion from a 2D image and wrap a line pattern around it?
Accepted offer letter, position changed
Did Carol Danvers really receive a Kree blood tranfusion?
what is the meaning of 0x0? say when variable gets assigned to it, example: keccak256(number) = 0x0;
Using the “Publish” button of Solidity Online CompilerNot able to read Array of Addresses in FunctionWhat is uint256?What does “0x0 Transaction mined but execution failed” mean when attempting to deploy via Remix on Rinkeby?What is the keccak256 reference in opcodes from solc?What is the meaning of “Expressions that might have a side-effect on memory allocation are allowed”?Why do people hash the address?Why send ether to 0x0 if user accidentally sends to contract?how to hash an array of address?Transaction reverted during contract execution [Reverted]
Is 0x0 just zero? thanks
keccak256(number) = 0x0;
Or when not used as address I mean just to denote variable?
solidity remix
add a comment |
Is 0x0 just zero? thanks
keccak256(number) = 0x0;
Or when not used as address I mean just to denote variable?
solidity remix
add a comment |
Is 0x0 just zero? thanks
keccak256(number) = 0x0;
Or when not used as address I mean just to denote variable?
solidity remix
Is 0x0 just zero? thanks
keccak256(number) = 0x0;
Or when not used as address I mean just to denote variable?
solidity remix
solidity remix
asked 7 hours ago
kpopguykpopguy
374
374
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
The example given wouldn't actually work because you're trying to assign 0x0
to the keccak
function.
It has the same meaning as bytes32(0)
. So, you can go:
require(bytes32(0) == 0x0);
That would be comparing equivalents. It was possible to compare address
and 0x0
but the trend seems to be toward explicit type casting, so you would go address(0)
with a recent compiler.
This type of expression is often used to validate inputs, in particular, catching important values that were not passed in. This is common:
function doSomething(bytes32 key) ...
require(key != 0x0);
// carry on
Hope it helps.
add a comment |
The 0x
prefix means hexadecimal and it's a way to tell programs, contracts, APIs that the input should be interpreted as a hexadecimal number (we'll shorten to hex). 0x0
is actually 0
but in hex. Usually we use 0x0
to check whether the address is not set by us and it is set to default value by the solidity which is 0x0.
require(_addressIn != address(0))
E.g. 0x0
in Solidity is short for 0x0000000000000000000000000000000000000000
, and if we use this as some address than it does have value greater than zero. check here.
Keccak256
computes the Ethereum-SHA-3 (Keccak-256) hash (doc) of the arguments passed into the function. So the above line of code is not correct because keccak256(number)
is returning the hash value which you can store in some variable, instead you are trying to treat the output hash value as an variable and assigning the 0x0
to that.
I hope it helps.
New contributor
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means0
.
– smarx
5 hours ago
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%2f68238%2fwhat-is-the-meaning-of-0x0-say-when-variable-gets-assigned-to-it-example-kecc%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
The example given wouldn't actually work because you're trying to assign 0x0
to the keccak
function.
It has the same meaning as bytes32(0)
. So, you can go:
require(bytes32(0) == 0x0);
That would be comparing equivalents. It was possible to compare address
and 0x0
but the trend seems to be toward explicit type casting, so you would go address(0)
with a recent compiler.
This type of expression is often used to validate inputs, in particular, catching important values that were not passed in. This is common:
function doSomething(bytes32 key) ...
require(key != 0x0);
// carry on
Hope it helps.
add a comment |
The example given wouldn't actually work because you're trying to assign 0x0
to the keccak
function.
It has the same meaning as bytes32(0)
. So, you can go:
require(bytes32(0) == 0x0);
That would be comparing equivalents. It was possible to compare address
and 0x0
but the trend seems to be toward explicit type casting, so you would go address(0)
with a recent compiler.
This type of expression is often used to validate inputs, in particular, catching important values that were not passed in. This is common:
function doSomething(bytes32 key) ...
require(key != 0x0);
// carry on
Hope it helps.
add a comment |
The example given wouldn't actually work because you're trying to assign 0x0
to the keccak
function.
It has the same meaning as bytes32(0)
. So, you can go:
require(bytes32(0) == 0x0);
That would be comparing equivalents. It was possible to compare address
and 0x0
but the trend seems to be toward explicit type casting, so you would go address(0)
with a recent compiler.
This type of expression is often used to validate inputs, in particular, catching important values that were not passed in. This is common:
function doSomething(bytes32 key) ...
require(key != 0x0);
// carry on
Hope it helps.
The example given wouldn't actually work because you're trying to assign 0x0
to the keccak
function.
It has the same meaning as bytes32(0)
. So, you can go:
require(bytes32(0) == 0x0);
That would be comparing equivalents. It was possible to compare address
and 0x0
but the trend seems to be toward explicit type casting, so you would go address(0)
with a recent compiler.
This type of expression is often used to validate inputs, in particular, catching important values that were not passed in. This is common:
function doSomething(bytes32 key) ...
require(key != 0x0);
// carry on
Hope it helps.
answered 7 hours ago
Rob HitchensRob Hitchens
28.7k74481
28.7k74481
add a comment |
add a comment |
The 0x
prefix means hexadecimal and it's a way to tell programs, contracts, APIs that the input should be interpreted as a hexadecimal number (we'll shorten to hex). 0x0
is actually 0
but in hex. Usually we use 0x0
to check whether the address is not set by us and it is set to default value by the solidity which is 0x0.
require(_addressIn != address(0))
E.g. 0x0
in Solidity is short for 0x0000000000000000000000000000000000000000
, and if we use this as some address than it does have value greater than zero. check here.
Keccak256
computes the Ethereum-SHA-3 (Keccak-256) hash (doc) of the arguments passed into the function. So the above line of code is not correct because keccak256(number)
is returning the hash value which you can store in some variable, instead you are trying to treat the output hash value as an variable and assigning the 0x0
to that.
I hope it helps.
New contributor
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means0
.
– smarx
5 hours ago
add a comment |
The 0x
prefix means hexadecimal and it's a way to tell programs, contracts, APIs that the input should be interpreted as a hexadecimal number (we'll shorten to hex). 0x0
is actually 0
but in hex. Usually we use 0x0
to check whether the address is not set by us and it is set to default value by the solidity which is 0x0.
require(_addressIn != address(0))
E.g. 0x0
in Solidity is short for 0x0000000000000000000000000000000000000000
, and if we use this as some address than it does have value greater than zero. check here.
Keccak256
computes the Ethereum-SHA-3 (Keccak-256) hash (doc) of the arguments passed into the function. So the above line of code is not correct because keccak256(number)
is returning the hash value which you can store in some variable, instead you are trying to treat the output hash value as an variable and assigning the 0x0
to that.
I hope it helps.
New contributor
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means0
.
– smarx
5 hours ago
add a comment |
The 0x
prefix means hexadecimal and it's a way to tell programs, contracts, APIs that the input should be interpreted as a hexadecimal number (we'll shorten to hex). 0x0
is actually 0
but in hex. Usually we use 0x0
to check whether the address is not set by us and it is set to default value by the solidity which is 0x0.
require(_addressIn != address(0))
E.g. 0x0
in Solidity is short for 0x0000000000000000000000000000000000000000
, and if we use this as some address than it does have value greater than zero. check here.
Keccak256
computes the Ethereum-SHA-3 (Keccak-256) hash (doc) of the arguments passed into the function. So the above line of code is not correct because keccak256(number)
is returning the hash value which you can store in some variable, instead you are trying to treat the output hash value as an variable and assigning the 0x0
to that.
I hope it helps.
New contributor
The 0x
prefix means hexadecimal and it's a way to tell programs, contracts, APIs that the input should be interpreted as a hexadecimal number (we'll shorten to hex). 0x0
is actually 0
but in hex. Usually we use 0x0
to check whether the address is not set by us and it is set to default value by the solidity which is 0x0.
require(_addressIn != address(0))
E.g. 0x0
in Solidity is short for 0x0000000000000000000000000000000000000000
, and if we use this as some address than it does have value greater than zero. check here.
Keccak256
computes the Ethereum-SHA-3 (Keccak-256) hash (doc) of the arguments passed into the function. So the above line of code is not correct because keccak256(number)
is returning the hash value which you can store in some variable, instead you are trying to treat the output hash value as an variable and assigning the 0x0
to that.
I hope it helps.
New contributor
New contributor
answered 5 hours ago
Abdullah AzizAbdullah Aziz
311
311
New contributor
New contributor
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means0
.
– smarx
5 hours ago
add a comment |
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means0
.
– smarx
5 hours ago
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means
0
.– smarx
5 hours ago
"0x0 in Solidity is short for 0x0000000000000000000000000000000000000000" I guess technically that's true, just like in decimal, 0 is short for 0000000000 (for any number of 0s). But I think it's misleading to say that, as it makes people think it represents some special value or some specific type. It just means
0
.– smarx
5 hours ago
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%2f68238%2fwhat-is-the-meaning-of-0x0-say-when-variable-gets-assigned-to-it-example-kecc%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