Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not understand the logic of transfering msg.value #42

Open
yeuyeuh opened this issue Mar 2, 2022 · 3 comments
Open

Do not understand the logic of transfering msg.value #42

yeuyeuh opened this issue Mar 2, 2022 · 3 comments

Comments

@yeuyeuh
Copy link

yeuyeuh commented Mar 2, 2022

Hi,

I'm trying to learn solidity. I think I misunderstood something.

Here you said that :

payable(idToMarketItem[tokenId].seller).transfer(msg.value);

but just before you said that the seller is address(0) :

idToMarketItem[tokenId].seller = payable(address(0));

So what I understand is that instead of transfering the msg.value to the old owner, you transfer it to address(0). Do you want to do that or I didn't understand it correctly ?

Thank you,
Inaki

@ghost
Copy link

ghost commented Mar 2, 2022

I think that's wrong when i buy nft the ethereum value dissapear into thin air becasue of seller address becoming address(0) but after moving
idToMarketItem[tokenId].seller = payable(address(0));
after
payable(idToMarketItem[tokenId].seller).transfer(msg.value);
its working perfectly.

@yeuyeuh
Copy link
Author

yeuyeuh commented Mar 2, 2022

Ok thank you !
How do you check that with the HardHat test?
I tried to had these 2 lines but I get "0" :

    const buyerBalance = await nftMarketplace.balanceOf(buyerAddress.address);
    console.log('buyerBalance: ', buyerBalance.toString())

So I think that balanceOf() is not the right function.
Do you have a suggestion?

@ghost
Copy link

ghost commented Mar 4, 2022

i have no clue about that i am learning myself and playing with it using truffle >.>
I am basically experimenting it for my use,so i wanted to move out of hardhat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant