'Is it possible to get the ABI of a contract without the source code?

Is it possible to get the ABI of a known contract address without the source code? The only way I've found is by using etherscan's API, but it only works for verified contracts. Any help is appreciated, thanks!



Solution 1:[1]

I guess you want the ABI to call functions on the contract,

You can still interact with contracts without the ABI, if you know the function signature of the function you want to call:

let test = await provider.call({
    // contract we want to talk to
    to: address,

    // `function name() view returns (string)`
    data: "0x313ce567",
});
console.log(`Decimals: ${test}`)

Decimals: 0x0000000000000000000000000000000000000000000000000000000000000009

Solution 2:[2]

The ABI JSON is generated from the source code. So unless you know the source code, there's no source to generate the ABI JSON from.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kayaba_Attribution
Solution 2 Petr Hejda