I'm trying to interact with smart contracts on the RSK Mainnet, and I'm getting this error...
Provided address "0xAb2d290b7a600f5eA8d5B933f6F15c867Fd7e60e" is invalid,
the capitalization checksum test failed,
or its an indirect IBAN address which can't be converted.
The address is obtained from RSK Explorer itself, so I'm not sure why web3.js has this error.
As per RSKIP-60, RSK network has its own checksum validation following EIP1191.
However, some tools and libraries still don't support EIP-1191.
Most Ethereum tools and libraries support EIP-155 only. web3.js is one of them, and it checks the checksum expecting an EIP-155 checksum.
Workarounds
(1) Convert the smart contract address to an all-lowercase string:
return new web3.eth.Contract(coinBackAbi, tokenObj.address.toString().toLowerCase());
Note that both EIP-155 and EIP-1191 define that all-lowercase addresses are to be treated as "skip checksum".
(2) Another approach is to use @rsksmart/rsk-utils
,
using this to convert the address to use the appropriate checksum:
// Ethereum --> use this for web3.js
toChecksumAddress ("0xAb2d290b7a600f5eA8d5B933f6F15c867Fd7e60e", null)
// RSK Mainnet
toChecksumAddress ("0xAb2d290b7a600f5eA8d5B933f6F15c867Fd7e60e", 30)