0

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

2 Answers 2

2

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.

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

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 and acknowledge you have read our privacy policy.

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