Skip to content

Allow hex strings without 0x prefix - #104

Open
zemse wants to merge 1 commit into
quilt:masterfrom
zemse:allow-no-prefix
Open

Allow hex strings without 0x prefix#104
zemse wants to merge 1 commit into
quilt:masterfrom
zemse:allow-no-prefix

Conversation

@zemse

@zemse zemse commented Aug 2, 2022

Copy link
Copy Markdown

Motivation

The "0x" prefix solves the ambiguity for the string "11", which could represent eleven or seventeen. Hence, it makes sense to include "0x" prefix everywhere in general.

However, a lot of popular tools in the ecosystem omit "0x" prefix. E.g. Bytecode from Remix, Hardhat, Solc compiler, evm.codes playground. And this does not create any ambiguity at all, since bytecode is supposed to be in hex format. Etk cli does not accept bytecode in a different format. Hence, flexibility can be provided to accept a hex string with or without "0x" prefix, for improving the convenience of the dev/user.

A related case: ethers.js is quiet strict with requirement of "0x" prefix, but the requirement of the prefix for private keys was made optional, because a lot of common tools do not prefix private keys with a 0x ethers-io/ethers.js@29f6c34

Before:

disease --code 60026001b46001b360005260206000F3 
error: Invalid value for '--code <code>': missing 0x prefix

After

disease --code 60026001b46001b360005260206000F3 
// works

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.

1 participant