Skip to content

docs: add recipient address encoding guide for Solana-to-Base transfers#191

Open
faisalnugroho wants to merge 1 commit into
base:mainfrom
faisalnugroho:docs/recipient-encoding
Open

docs: add recipient address encoding guide for Solana-to-Base transfers#191
faisalnugroho wants to merge 1 commit into
base:mainfrom
faisalnugroho:docs/recipient-encoding

Conversation

@faisalnugroho
Copy link
Copy Markdown

Summary

Fixes #190

The TokenLib.finalizeTransfer() function decodes EVM recipient addresses using address(bytes20(transfer.to)), which takes the first 20 bytes (left-aligned) of the bytes32 value. This is easy to misuse because common Solidity-style address-to-bytes32 encoding is often right-aligned.

Changes

Added a new section to base/README.md documenting:

  • Correct encoding: bytes32(bytes20(evmAddress)) — left-aligned
  • Incorrect encoding: bytes32(uint256(uint160(evmAddress))) — right-aligned (will decode wrong address)
  • Quick reference table for all transfer directions
  • JavaScript/TypeScript helper using viem's pad() function

Fixes base#190

- Document that TokenLib.finalizeTransfer() uses left-aligned bytes20
- Add correct vs incorrect encoding examples in Solidity
- Add quick reference table for all transfer directions
- Add JavaScript/TypeScript helper using viem's pad()
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@faisalnugroho
Copy link
Copy Markdown
Author

Hi! Following up on this docs PR. This PR documents the recipient address encoding requirements for Solana-to-Base bridge transfers, including the hex encoding format and common pitfalls.

All CI checks pass (StepSecurity ✅). Would love to get your review when you have a moment. Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Solana-to-Base transfer.to recipient encoding is not clearly documented and is easy to misuse

2 participants