It appears cleos has no way of returning a list of active smart-contracts. Is there another way?
2 Answers
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?– KabirCommented 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. Commented Nov 23, 2018 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.