I create a contract with ERC-721 and I try to transfer the token with money. I am using web3.js and openzeppelin. So, The transaction is confirmed, but no money is sent to the target wallet.
Here is the contract buy function;
function buy(uint256 _tokenId) public payable { address buyer = msg.sender; require(_isApprovedOrOwner(msg.sender, _tokenId), "ERC721: transfer caller is not owner nor approved"); approve(buyer, _tokenId); safeTransferFrom(ownerOf(_tokenId), buyer, _tokenId); }
And here is web3.js :
const buy = (2,2) => { //Token ID: 2 //Price: 2 ether contract.methods.buy(2).send({ from: account, value: web3.utils.toWei(2, 'ether') }) }
Please help me. Thank you.