docs: add recipient address encoding guide for Solana-to-Base transfers#191
Open
faisalnugroho wants to merge 1 commit into
Open
docs: add recipient address encoding guide for Solana-to-Base transfers#191faisalnugroho wants to merge 1 commit into
faisalnugroho wants to merge 1 commit into
Conversation
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()
Collaborator
🟡 Heimdall Review Status
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #190
The
TokenLib.finalizeTransfer()function decodes EVM recipient addresses usingaddress(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.mddocumenting:bytes32(bytes20(evmAddress))— left-alignedbytes32(uint256(uint160(evmAddress)))— right-aligned (will decode wrong address)pad()function