Reference
Messages
The Cron module accepts messages through governance proposals only.
MsgAddSchedule
Creates a new schedule through governance proposal.
message MsgAddSchedule {
string authority = 1; // The address of the governance account
string name = 2; // Unique identifier for the schedule
uint64 period = 3; // Number of blocks between executions
repeated MsgExecuteContract msgs = 4; // Messages to execute
ExecutionStage execution_stage = 5; // Execution stage (BEGIN_BLOCKER or END_BLOCKER)
}
MsgRemoveSchedule
Removes an existing schedule through governance proposal.
message MsgRemoveSchedule {
string authority = 1; // The address of the governance account
string name = 2; // Name of the schedule to remove
}
MsgUpdateParams
Updates the module parameters through governance proposal.
message MsgUpdateParams {
string authority = 1; // The address of the governance account
Params params = 2; // New module parameters
}
State
Schedule
The primary state object in the Cron module:
message Schedule {
string name = 1; // Unique identifier for the schedule
uint64 period = 2; // Number of blocks between executions
repeated MsgExecuteContract msgs = 3; // Messages to execute when triggered
uint64 last_execute_height = 4; // Last block height when executed
ExecutionStage execution_stage = 5; // Execution stage
}
MsgExecuteContract
Defines the contract and the message to execute:
message MsgExecuteContract {
string contract = 1; // The address of the smart contract
string msg = 2; // JSON encoded message to be passed to the contract
}
ExecutionStage
Defines when messages will be executed in the block:
enum ExecutionStage {
EXECUTION_STAGE_END_BLOCKER = 0; // Execution at the end of the block
EXECUTION_STAGE_BEGIN_BLOCKER = 1; // Execution at the beginning of the block
}
Params
Module-wide parameters:
message Params {
string security_address = 1; // Security address that can remove schedules
uint64 limit = 2; // Limit of schedules executed in one block
}
ScheduleCount
Tracks the number of current schedules:
message ScheduleCount {
int32 count = 1; // The number of current schedules
}
Query Methods
Params
Returns the module parameters.
CLI Usage:
neutrond query cron params
gRPC Endpoint:
/neutron/cron/params
Schedule
Returns a specific schedule by name.
CLI Usage:
neutrond query cron show-schedule [schedule-name]
gRPC Endpoint:
/neutron/cron/schedule/{name}
Schedules
Returns all schedules with pagination support.
CLI Usage:
neutrond query cron list-schedule
gRPC Endpoint:
/neutron/cron/schedule
Events
The Cron module does not emit any custom events. Schedule execution and management operations are logged but do not generate blockchain events.
Metrics
The Cron module collects several metrics for monitoring:
execute_ready_schedules(histogram): Time taken to execute all ready schedulesschedule_count(gauge): Current number of active schedulesschedule_executions_count(counter): Total schedule executions, labeled by success/failure and schedule name
Client
Query Commands
The neutrond CLI provides commands to query the Cron module:
# Get all schedules
neutrond query cron list-schedule
# Get a specific schedule
neutrond query cron show-schedule [schedule-name]
# Get module parameters
neutrond query cron params
Governance Proposals
Since the Cron module is governance-gated, schedules can only be managed through governance proposals:
# Submit a governance proposal to add a schedule
neutrond tx gov submit-proposal [proposal-file]
# Submit a governance proposal to remove a schedule
neutrond tx gov submit-proposal [proposal-file]
Example proposal file to add a schedule:
{
"title": "Add Cron Schedule",
"description": "Add a new cron schedule for periodic operations",
"messages": [
{
"@type": "/neutron.cron.MsgAddSchedule",
"authority": "neutron1...",
"name": "my-schedule",
"period": "100",
"msgs": [
{
"contract": "neutron1...",
"msg": "{\"execute_action\": {}}"
}
],
"execution_stage": "EXECUTION_STAGE_END_BLOCKER"
}
]
}
API Endpoints
gRPC Service
service Query {
// Parameters queries the parameters of the module
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/neutron/cron/params";
}
// Queries a Schedule by name
rpc Schedule(QueryGetScheduleRequest) returns (QueryGetScheduleResponse) {
option (google.api.http).get = "/neutron/cron/schedule/{name}";
}
// Queries a list of Schedule items
rpc Schedules(QuerySchedulesRequest) returns (QuerySchedulesResponse) {
option (google.api.http).get = "/neutron/cron/schedule";
}
}
HTTP REST Endpoints
GET /neutron/cron/params- Get module parametersGET /neutron/cron/schedule/{name}- Get specific scheduleGET /neutron/cron/schedule- Get all schedules