0

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

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.

  • 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
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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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