It appears cleos has no way of returning a list of active smart-contracts. Is there another way?


Most accounts with smart contracts deployed on the mainnet would have abi info provided. With mongo_db_plugin of nodeos, you could list all accounts with abi field in mongodb.

db.accounts.count({abi: {$exists: true}})

Current result is 1858.

  • Thanks. How did you do this query? Is there a way to do this using cleos?
    – Kabir
    Nov 23 '18 at 16:15
  • @Kabir You need to setup a nodeos instance with mongo_db_plugin enabled, and then query that mongodb instance.
    – Tong Shen
    Nov 23 '18 at 16:16

If you have a snapshot of the accounts available, you can do cleos get code ACCOUNT_NAME. If the result is zero, then the account has no smart contract attached to it. Otherwise it does. Loop through all the accounts and sum all the ones with non-zero code hashes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.