Summary
sdk.api2.abi.multiCall rejects calls whose target or params are EIP-55 mixed-case addresses with Error: Bad encoding, while sdk.api2.abi.call accepts the exact same arguments without complaint. Lowercasing the addresses works around it for multiCall.
This is surprising because:
- EIP-55 checksummed addresses are the canonical form (Etherscan, deployment manifests, etc.).
- The asymmetry between
call and multiCall for byte-identical input means an adapter that runs cleanly for a single read suddenly breaks when batched.
Environment
@defillama/sdk 5.0.211
- Node 22
Minimal reproduction
const sdk = require('@defillama/sdk');
(async () => {
const target = '0xA0b86991c6218b36c1D19D4a2e9Eb0cE3606eB48'; // USDC, EIP-55
const owner = '0x40ec5B33f54e0E8A33A975908C5BA1c14e5BbbDf'; // Polygon predicate, EIP-55
const abi = 'function balanceOf(address) view returns (uint256)';
// 1. call — mixed case → OK
console.log(await sdk.api2.abi.call({ chain: 'ethereum', target, abi, params: [owner] }));
// 2. multiCall — same input → FAILS
try {
await sdk.api2.abi.multiCall({
chain: 'ethereum', abi, calls: [{ target, params: [owner] }],
});
} catch (e) {
console.log('multiCall (mixed case):', e.message.split('\n')[0],
'underlying:', e._underlyingErrors);
}
// 3. multiCall — same input but lowercased → OK
console.log(await sdk.api2.abi.multiCall({
chain: 'ethereum', abi,
calls: [{ target: target.toLowerCase(), params: [owner.toLowerCase()] }],
}));
})();
Output
1102611120377950 // (1) call OK
multiCall (mixed case): Multicall failed! underlying: [ 'Error: Bad encoding' ]
[ '1102611120377950' ] // (3) lowercase multiCall OK
Impact
For the common case of pasting Etherscan-canonical addresses into an adapter, the developer hits an opaque Bad encoding only at batch time, with no hint that lowercase fixes it. Surfaced while writing PoR adapters in DefiLlama/defillama-server#PR_LINK_TBD — the workaround there is to write all addresses lowercase, but a saner fix would be to checksum-normalize inside multiCall the way call evidently already does (or share whatever normalization step call uses).
Happy to open a PR with a normalization fix if pointing me at the right module would help — looks like it would land somewhere around the multicall encoder path.
Summary
sdk.api2.abi.multiCallrejects calls whosetargetorparamsare EIP-55 mixed-case addresses withError: Bad encoding, whilesdk.api2.abi.callaccepts the exact same arguments without complaint. Lowercasing the addresses works around it formultiCall.This is surprising because:
callandmultiCallfor byte-identical input means an adapter that runs cleanly for a single read suddenly breaks when batched.Environment
@defillama/sdk5.0.211Minimal reproduction
Output
Impact
For the common case of pasting Etherscan-canonical addresses into an adapter, the developer hits an opaque
Bad encodingonly at batch time, with no hint that lowercase fixes it. Surfaced while writing PoR adapters in DefiLlama/defillama-server#PR_LINK_TBD — the workaround there is to write all addresses lowercase, but a saner fix would be to checksum-normalize insidemultiCallthe waycallevidently already does (or share whatever normalization stepcalluses).Happy to open a PR with a normalization fix if pointing me at the right module would help — looks like it would land somewhere around the multicall encoder path.