On RSK public testnet, I create my RSK wallet with ethers like this:
const wallet = await ethers.Wallet.createRandom()
Then the address is: 0x68C06960f0Cd2bB0318673F157243Ad545AbbE2A
When I send an amount to it, and explore the transaction on RSK testnet explorer, the actual destination address of the transaction has a difference in case (EIP-1191) 0x68C06960f0CD2bB0318673f157243aD545AbBE2a
How can I make ethers generate the address in the right checksum case right away? Does it really matter at the end? Ideally, I would like to be enforce the chainId in the transaction request so that I am sure that my transaction will not occur on any other chain than RSK.
Thanks
As the comment above mentions, ethers doesn't accept the chainId as a property, however, the @rsksmart/rsk-util library does. Specifically, the toChecksumAddress() method.
It would be like this:
If you pass a RSK checksummed address to Ethers it will throw an error that the checksum is incorrect. This is because Ethers only checks for the Ethereum version. So, before sending an address back to Ethers, convert it to lowercase.
The checksum should be used when you are displaying it to the end user. It won't prevent an address being used on multiple networks, but it is an indication/caution to the user that perhaps the address they typed/pasted in might be for a different network.
About a year ago I wrote a blog post about this, Checksums are for humans, not computers.