0

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?

OguzKaanAkyalcin
  • 621
  • 2
  • 8
  • 25

2 Answers2

1

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.

Petr Hejda
  • 40,554
  • 8
  • 72
  • 100
  • Thank you for the answer. But especially during the development process, I always need to request ABI from solidity developers and update my project. I think If I access to ABI by address of the smart contract I will save alot of time. Do you any suggestions for this? – OguzKaanAkyalcin May 20 '21 at 11:22
  • Unless you can get the source code by address, it's not technically possible to generate the json from just address. It needs to be generated from the contract source code... "If I access to ABI by address of the smart contract" - It depends on your context, whether the contract authors have published their source code and whether the set (of source codes) is accessible in some searchable format (by address). – Petr Hejda May 20 '21 at 11:47
0

You could copy your smartcontract into remix and let remix compile it. Remix then shows you the Api and the bytecode of your contract.