Say I have a hex string c4ef705a8a8f2db126b92013b4938230df2158b5 how can I format it as a solidity address using ethers js or another npm package to prepend 0x and correctly capitalise some of the alphabetical hex characters like so: 0xc4ef705a8a8F2Db126B92013B4938230DF2158b5

1 Answer 1


After a small investigation the ethers.utils.getAddress function formats the address as desired.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.