Just a quick drop in… what the hell does address[0]
in solidity mean?
Hi @William
You use address(0)
in Solidity to refer to the address (0x0000000000000000000000000).
You use accounts[0]
in web3 in order to refer to the address the user is using on its wallet and that will interact with your contract.
Regards,
Dani
I am still not understanding. I’ve done a ton of research on it and I just don’t get it. Can you explain to me a use case for address[0]? Maybe, if you did explain it above, you could try to explain it a different way? i’m sorry for the inconvenience, i just really want to get this…
address[0]
does not exist in solidity, the term for solidityis address(0)
has @dan-i already explain to you.
Where did you see that being used??
For truffle or web3 you use accounts
which will contain the addresses from a private key (generated by default or manually set), then you can use the 1st address has accounts[0]
for example, or 2nd address has accounts[1]
.
Hope I explained myself clear, if not let me know
Carlos Z
Oh ok, I see I was using brackets. Here is the example i’m confused about:
_transfer(address(0), _owner, newKittenId);
the first argument in this function will always use address(0)… Is this dynamic? Does it change with whoever is interacting with this function…?
In that example, it is hardcoded to transfer a newKittenId
fromaddress(0)
to _owner
its only for newKitties, which is not owned by no one at the creation moment (mint).
but lets say the example of: from _owner to another address.
That would be the same _transfer
function but something like this:
_transfer(newOwner, msg.sender, kittyId);
that way, you are transfering your nft to another account.
Carlos Z