base / base/op-viem

Missing ERC20 Functionality

Open
#124 0 comments 0 reactions 0 assignees View on GitHub
state: backlog type: enhancement
Dominant language
TypeScript
Stars
371
Forks
248
PR merge metrics
No merged PRs in 30d

Description

## Context

The following functionality is missing from the ERC20 story

## Major missing functionality

- [ ] Add native l2 tokens support- Native l2 tokens require using one of the `bridgeERC20` methods rather than a `withdraw`. Withdraw is only for mintable tokens not native tokens
- [ ] Deposit token is unsafe - It's easy to lose tokens depositing with the current method because no validation is happening to validate the token is bridgable. At a minimum we should documenting this. Note this is kinda tricky. Validating a mintable token withdrawal is simple since it's all done on l2. Validating an l1 deposit matches l2 is less simple as it requires an l2 public client. The correct solution for now is to document it until higher level multiclient aware abstractions are made
- [ ] No legacy withdrawal support - Prebedrock withdrawals on OP mainnet do not have any support. Pre bedrock withdrawals are not 1559 therefore require extra work to get working encoding and decoding.

## Minor missing functionality

- [ ] Add documentation about how to reliably get the bridge and token info from a token address - To use the erc20 bridge well one should be getting the l1 and l2 token info and the bridge info from the l2 token or from the tokenlist
```typescript
// example
const l2BridgeAddress = l2MintableToken.l2Bridge()
const l1TokenAddress = l2MintableToken.l1Token()

client.withdrawERC20({
...sameOptionsAsBefore,
address: l2BridgeAddress,
```
- [ ] Add action for getting token info - It would be nice if viem had a native way of getting stuff like the bridge address and matching token too

- [ ] No preregensis support - preregenisis are before the version of optimism that was before bedrock. My suggestion is to not support this completely but simply add a single sentence to the docs about this not being supported.

Contributor guide

Open the contributing guide

Research direction

Start by locating the ERC20 actions and the bridgeERC20, withdraw, and withdrawERC20 entry points referenced in the issue. Review how l2MintableToken exposes l2Bridge() and l1Token(), then define separate completion criteria for native L2 tokens, deposit safety documentation, legacy withdrawals, token-info retrieval, and preregenesis support.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, blockchain
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.