-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
ERC721 payable transferFrom #2610
Comments
Hello @olegabr and thanks for the notice. A reason why we did not make them payable in our implementation is to avoid funds getting stuck since there is no mechanism to withdraw any fund that might be sent by mistake ... |
@Amxx Thank you for your prompt response! |
There is no clean way for us to make the interface I believe this is a limitation of the language so I've opened an issue about it. ethereum/solidity#11253 In the mean time, I'm going to close the PR because it doesn't allow child contracts to cleanly remove the |
Related issue in the ERC-721 reference implementation: nibbstack/erc721#144 Because this is a known issue (read the caveats section in ERC-721 if you want to see a bunch of known Solidity issues), and because we are using Solidity, I recommend this work plan for this issue:
|
Thanks for the suggestion @fulldecent. We will keep the issue open with the tag |
@olegabr |
@adriadrop ETH can not be used because of this issue. But ERC20 can :-) |
Ok, but ETH could been use seemlesly, with weth you have UX problem, people
needing to have weth or you needing to transact it for them.
ned, 15. kol 2021. 05:58 Oleg Abrosimov ***@***.***> je
napisao:
… @adriadrop <https://github.com/adriadrop> ETH can not be used because of
this issue. But ERC20 can :-)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2610 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACEN4J2FKNTI5PWDTEA7XODT443NPANCNFSM4ZYZ5NLQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
The whole crypto space has a huge UI/UX issue. That is why I'm developing tools to hide crypto from users altogether, and let them pay with fiat if they want: https://ethereumico.io/shop/ |
Hello. Can you offer an alternative or suggest a pattern ? |
This issue here can track upstream Solidity support for payable/nonayable override. And @frangio is doing a great job advocating over there. But for all this discussion about royalty (which is a supported NFT use case) perhaps Stack Exchange or similar is a better place to discuss. |
It was in my opinion that you cannot call payable function from non payable function, but it is possible.
So, the lack of payable version of the transferFrom is no more a problem. |
I had to make my own // SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/utils/introspection/IERC165.sol';
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Payable is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external payable;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(
uint256 tokenId
) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(
address owner,
address operator
) external view returns (bool);
} |
Duplicate of #1015 |
openzeppelin-contracts/contracts/token/ERC721/IERC721.sol
Line 70 in 378531b
Hello,
I'm trying to implement royalty in ERC721 token. The idea is to have a
wantToSell
method to set a price for a token, if you want to allow someone to buy it, and atransferFrom payable
method to allow buyer to call it providing enough value ETH.The royalty is distributed to the token contract owner and token ID author in all subsequent re-sells.
The problem is that the
transferFrom
function declared without thepayable
modifier and the solidity compiler complains if I try to override thetransferFrom
function adding thepayable
modifier myself.The standard declares the
transferFrom
method as apayable
https://eips.ethereum.org/EIPS/eip-721The text was updated successfully, but these errors were encountered: