blockchainsolidityquorumazure-blockchain-servicenethereum

How to get ABI of Smart Contract with Nethereum?


I can access a Blockchain Service based on Quorum, and I'm using Nethereum Library to interact with Smart Contract.

When I deploy a new Smart Contract, Nethereum gives the address and the ABI of SmartContract.

But I can't access the ABI of SmartContract without deploying the process. How can I get ABI based on the address of Smart Contract?


Solution

  • You can get ABI JSON during compilation of the contract source code. The inputs for compilation are source code and few other values (such as optimizer settings)... The outputs include the ABI JSON and bytecode... So you don't really need to deploy the contract to get the json, just compile it (without deployment).

    It's not possible to get ABI JSON purely from a bytecode (or an address that contains just the bytecode).


    If the contract has source code published, you can compile the source code to get the ABI JSON.

    If if doesn't have the source code published, it's also possible that the contract implements some standard (e.g. ERC-20). If you know whether and what standard it implements, you can use a general ABI JSON that reflects on this standard (e.g. this is ABI JSON of a ERC-20 standard). However, it does not reflect any functions that the contract might have used to extend the standard-defined minimum.