New Smart Contracts
New Smart Contracts counts contract entities created on Hedera during the chosen period.
To access this Hedera network statistic (and others) via Hgraph's GraphQL & REST APIs, get started here.
Hedera Stat Name: new_smart_contracts
Methodology
Qualifying Contract Creations
To be counted as a new smart contract, an event must satisfy all the following criteria:
- Entity Type: The entity must be a smart contract (
entity.type = 'CONTRACT'
). - Direct Transaction Match: The entity’s
created_timestamp
must exactly match theconsensus_timestamp
of a transaction (entity.created_timestamp = transaction.consensus_timestamp
). - Transaction Type: The transaction must be a
CONTRACTCREATEINSTANCE
operation (transaction.type = 8
). See Hedera Mirror Node transaction codes for all type and result definitions. - Transaction Success: The transaction must have completed successfully (
transaction.result = 22
).
Example
If a smart contract is created at timestamp T
, and there is a transaction at T
of type 8
and result 22
, this contract is included in the metric.
GraphQL API Examples
Test out these queries using our developer playground.
Fetch current new smart contracts (hourly)
query NewContractsHour {
ecosystem_metric(
order_by: {end_date: desc_nulls_last}
limit: 1
where: {name: {_eq: "new_smart_contracts"}, period: {_eq: "hour"}}
) {
total
end_date
}
}
Fetch daily new smart contracts for 1 month (timeseries)
query DailyNewContracts {
ecosystem_metric(
order_by: {end_date: desc_nulls_last}
limit: 30
where: {name: {_eq: "new_smart_contracts"}, period: {_eq: "day"}}
) {
total
end_date
}
}
Available Time Periods
The period
field supports the following values:
hour
day
SQL Implementation
Below is a link to the Hedera Stats GitHub repository. The repo contains the SQL function that calculates the New Smart Contracts statistic outlined in this methodology.
SQL Function: ecosystem.dashboard_new_smart_contracts
Dependencies
- Hedera mirror node