Skip to content

add erc transfer from native #987

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

snreynolds
Copy link

When opening a pull request to submit a new EIP, please use the suggested template: https://github.com/ethereum/EIPs/blob/master/eip-template.md

We have a GitHub bot that automatically merges some PRs. It will merge yours immediately if certain criteria are met:

  • The PR edits only existing draft PRs.
  • The build passes.
  • Your GitHub username or email address is listed in the 'author' header of all affected PRs, inside .
  • If matching on email address, the email address is the one publicly listed on your GitHub profile.

@eip-review-bot
Copy link
Collaborator

eip-review-bot commented Mar 21, 2025

🛑 eip-review-bot failed for an unknown reason. Please see logs for more details, and report this issue at the eip-review-bot repository.

Copy link

The commit 8380220 (as a parent of 9a7b129) contains errors.
Please inspect the Run Summary for details.

status: Draft
type: Standards
category: ERC
created: <TODO>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should contain the date on which the proposal was initiated, regardless of its state.

Comment on lines +42 to +46
MUST emit the following event on success:

```solidity
event TransferFromNative(address indexed from, address indexed to, uint256 value);
```
Copy link
Contributor

@Vectorized Vectorized Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could clarify on what happens if amount = 0 re the event.

I think skip the emit and just return true?


MUST verify whether `msg.sender` (the caller) is authorized to execute the Native transfer.

MUST handle the Native transfer and return false on failure.
Copy link
Contributor

@Vectorized Vectorized Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could clarify on revert or return false (or perhaps either).

Imo, leaning more towards reverting, cleaner to implement.

Add rationale for choice.

Comment on lines +92 to +102
```solidity
interface ERC165 {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
```
Copy link
Contributor

@Vectorized Vectorized Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo, to avoid inheritance headaches, would prefer if there's some way to recycle one of the existing functions. Then no need for 165.

I think if we have some nativeAllowance(address spender), we can use it as a signaling mechanism. If nativeAllowance is to be implemented, maybe nativeAllowanceTransient should be implemented to differentiate? Or maybe nativeAllowance could be the saturating sum of the transient allowance and regular allowance.

Technically, transferFromNative with a zero amount could be used to signal too (if it doesn't emit any event), but implementing a staticcall to a non-view function in plain Solidity is ugly.


### Optional Transient Approval

For cases where approval should only persist within a single transaction, a transient approval mechanism MAY be used. This allows a user to grant temporary approval to a `spender` for a single transaction, without modifying persistent storage.
Copy link
Contributor

@Vectorized Vectorized Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think need clarity on which native allowance to deduct first. Would prefer transient to be deducted first. Cuz TLOAD costs less than SLOAD.

Also not sure if it is the saturating sum of transient and regular allowances. Or perhaps some other formula.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that is interesting. Yeah definitely needs some outline for order of operations. My gut impl would be to default first to transient like you said.

I'm not sure how we should handle the case then if there is more requested than the transient amount allowed. Do you then pull from the persisted allotment? It feels like that may be user error of the transient allotment if the caller didn't request enough to be allowed transiently?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it would be cleaner if we just separated them - transferFromNative and transferFromNativeTransient. that way it's easier to know which allowance to subtract from

To modify this approval, the following function MUST be implemented.

```solidity
function approveNative(address spender, uint256 amount) external returns (bool);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would also be good to include allowance(address spender) and transientAllowance(address spender) in the interface

- `recipient`: The recipient of the Native transfer.
- `amount`: The amount of Native to transfer.

SHOULD early return when amount == 0, otherwise anyone can execute any fallback function on any contract on behalf of the user without explicit approval.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should early return with true, same for transient function

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

Successfully merging this pull request may close these issues.

7 participants