Skip to content
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

fix: format web3_sha3 result as an hexadecimal string #6843

Merged
merged 2 commits into from
Jan 18, 2024

Conversation

leovct
Copy link
Contributor

@leovct leovct commented Jan 18, 2024

Motivation

The result returned by anvil web3_sha3 does not include the "0x" prefix in the hexadecimal string.

Comparing geth and anvil outputs, with the same parameter, we can see the difference:

# geth result
$ curl -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "web3_sha3", "params": ["0x68656c6c6f20776f726c64"], "id": 74}' http://localhost:8545
{"jsonrpc":"2.0","id":74,"result":"0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"}

# anvil result
$ curl -H 'Content-Type: application/json' -d '{"jsonrpc": "2.0", "method": "web3_sha3", "params": ["0x68656c6c6f20776f726c64"], "id": 74}' http://localhost:8545
{"jsonrpc":"2.0","id":74,"result":"47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad"}

Solution

Add the 0x prefix to the result of sha3.

Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

lgtm, just nit

crates/anvil/src/eth/api.rs Outdated Show resolved Hide resolved
@leovct leovct requested a review from Evalir January 18, 2024 17:08
@onbjerg onbjerg merged commit 8bd1483 into foundry-rs:master Jan 18, 2024
@leovct leovct deleted the fix/web3-sha3-result branch January 18, 2024 17:09
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.

3 participants