When I am using hardhat test network to transfer value between two accounts by smart contract, the value is decrease in one account, but there is no value increase in the target account. So what is actually transferred in the process? Very thank.
I found that the value is increase in Hardhat test environment. However, when I test on the browser, the value is not increase in the target account. (In the browser side, I am using Metamask.)
Here is my contract code
function purchasePost(uint256 _id, uint256 newPrice, bool _publish, bool _onSale) public payable{
require(ownerOf(_id) != address(0), "NFT does not exist");
require(posts[_id-1].onSale, "Post not selling");
require(msg.sender != posts[_id-1].owner, "You can't purchase your own post");
require(msg.value >= posts[_id-1].price, "Insufficient funds");
address payable seller = payable(ownerOf(_id));
address payable buyer = payable(msg.sender);
uint256 price = posts[_id - 1].price;
// Transfer ownership and payment
_transfer(seller, buyer, _id);
seller.transfer(price);
posts[_id-1].owner = msg.sender;
posts[_id-1].published = _publish;
posts[_id-1].onSale = _onSale;
posts[_id-1].price = newPrice;
posts[_id-1].previousPrice = price;
emit PostTransfer(_id, posts[_id-1].title, seller, buyer, price);
}