API Reference
The core methods and types available on the zapChain plugin instance.
Plugin Setup
constructor(config?)
new ZapChainPlugin(config?: ZapChainConfig)Initializes a new instance of the ZapChain automation plugin.
LocalStorageAdapter). Default: InMemory.12000 (12s).false.false.Rule Management
createRule(rule)
createRule(rule: Partial<RuleDefinition>): Promise<string>Creates and registers a new automation rule. Automatically detects connected wallet if metadata.createdBy is missing.
enableRule(ruleId)
enableRule(ruleId: string): Promise<void>Activates a rule. The engine will immediately start monitoring for trigger conditions.
disableRule(ruleId)
disableRule(ruleId: string): Promise<void>Deactivates a rule. It will simply be ignored by the engine loop.
deleteRule(ruleId)
deleteRule(ruleId: string): Promise<void>Permanently removes a rule from storage and stops its execution.
listRules()
listRules(): Promise<RuleInfo[]>Returns a list of all rules (active and disabled) currently managed by the plugin.
getRule(ruleId)
getRule(ruleId: string): Promise<RuleDefinition | undefined>Retrieves the full definition of a specific rule.
Execution & Safety
getExecutionLogs(ruleId?)
getExecutionLogs(ruleId?: string): ExecutionLog[]Returns the history of rule executions. Useful for debugging or UI history.
simulateRule(ruleId)
simulateRule(ruleId: string): Promise<SimulationResult>simulateRule(ruleId)
simulateRule(ruleId: string): Promise<SimulationResult>Runs an internal simulation using eth_call for all contract actions in the rule. Returns gas estimates and potential revert reasons without broadcasting a transaction.
setKillSwitch(enabled)
setKillSwitch(enabled: boolean): Promise<void>Emergency Stop. Globally pauses ALL rule executions when set to true.
isKillSwitchActive()
isKillSwitchActive(): booleanReturns the current status of the emergency kill-switch.
Condition Types
balance
Triggers based on wallet balance changes.
0x0 for ETH, or ERC20 contract address.>, <, ==, >=, <=.web3.utils.toWei).gas_price
Triggers when network gas price meets a target.
Action Types
contract_call
Executes a smart contract transaction.
native_transfer v2.0
Send ETH/MATIC directly to any address without requiring a contract ABI. Perfect for simple transfers, auto-sweeping, and tipping.
// Example: Auto-sweep to cold wallet
{
type: 'native_transfer',
to: '0xColdWallet...',
value: web3.utils.toWei('1', 'ether')
}notification
Send HTTP webhook notifications.
POST or GET.Execution Logging v2.0 Enhanced
ExecutionLog
Every rule execution is logged with detailed status information for debugging.
SUCCESS | FAILED | SKIPPEDKILL_SWITCH_ACTIVECOOLDOWN_ACTIVEMAX_EXECUTIONS_REACHEDSIGNATURE_INVALIDSIMULATION_FAILEDCONDITIONS_NOT_MET
Per-Rule Configuration v2.0
RuleConfig.pollInterval
Override the global polling interval for individual rules. Useful for time-sensitive conditions.
// Gas price monitoring every 1 second
config: {
pollInterval: 1000, // Override global 12s
simulateFirst: true
}