I have a hex literal that I need to pass into a contract using web3, and I'm not sure how to go about formatting it. In solidity, its formatted like so:


My function takes this and some other parameters, and passing like this works inside of Remix. Trying to pass like this results in an error in my javascript code however, since the hex keyword is not inside the quotes. I tried prepending 0x to the hexadecimal and dropping the keyword but my function is not returning the correct value when this is passed in.

I can't find any examples of this, nor very many that even use hexadecimal literals, so I would greatly appreciate any help that can be provided!

Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.