Skip to content

Commit 2e14d84

Browse files
huth-stacksclaude
andcommitted
Add Hiro Platform section with Contract Monitoring documentation
Creates a dedicated Hiro Platform subsection under build/ to properly contain platform-specific features. Faithfully migrates Contract Monitoring documentation from Hiro docs including complete webhook payload JSON, TypeScript interfaces, and step-by-step alert creation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 386a20a commit 2e14d84

4 files changed

Lines changed: 236 additions & 0 deletions

File tree

‎docs/build/SUMMARY.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@
8181
* [Implementation](post-conditions/implementation.md)
8282
* [Examples](post-conditions/examples.md)
8383

84+
## Hiro Platform
85+
86+
* [Overview](hiro-platform/README.md)
87+
* [Contract Monitoring](hiro-platform/contract-monitoring/README.md)
88+
* [Create an Alert](hiro-platform/contract-monitoring/create-alert.md)
89+
8490
## More Guides
8591

8692
* [sBTC](more-guides/sbtc/README.md)

‎docs/build/hiro-platform/README.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Hiro Platform
2+
3+
The [Hiro Platform](https://platform.hiro.so) is a hosted developer platform for building on Stacks. It provides a suite of tools and services that help you develop, deploy, and monitor your smart contracts without managing infrastructure.
4+
5+
{% hint style="info" %}
6+
Features in this section require a Hiro Platform account. [Sign up free](https://platform.hiro.so).
7+
{% endhint %}
8+
9+
## Platform features
10+
11+
The following platform-specific features are documented in this section:
12+
13+
- [**Contract Monitoring**](contract-monitoring/README.md) - Track smart contract events in real-time and receive webhook notifications when specific activities occur.
14+
15+
## Getting started
16+
17+
1. Create an account at [platform.hiro.so](https://platform.hiro.so).
18+
2. Explore the platform features listed above.
19+
3. Follow the step-by-step guides to integrate platform tools into your workflow.
20+
21+
{% hint style="info" %}
22+
### Need help with the Hiro Platform?
23+
24+
Reach out on the **#api** channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section.
25+
{% endhint %}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Contract Monitoring
2+
3+
Contract monitoring lets you track smart contract events in real-time and receive webhook notifications when specific activities occur.
4+
5+
## Key features
6+
7+
- **Real-time notifications** - Target specific events and receive webhooks within seconds
8+
- **No-code setup** - Configure monitors through the Platform UI without writing code
9+
10+
## When to use it
11+
12+
| Feature | Best for |
13+
| --- | --- |
14+
| **Contract Monitoring** | No-code, UI-based alerts for specific contract function calls on mainnet |
15+
| **Chainhooks** | Advanced, programmable event monitoring with custom predicates and self-hosted infrastructure |
16+
17+
Contract monitoring is ideal when you want quick, no-code alerts for contract activity. For more complex event-driven workflows, consider [Chainhooks](https://docs.hiro.so/tools/chainhooks).
18+
19+
## Next steps
20+
21+
- [Create an alert](create-alert.md): Set up your first alert for function calls.
22+
- [Chainhooks](https://docs.hiro.so/tools/chainhooks): Learn more about Chainhooks and how they differ from contract monitoring.
23+
24+
{% hint style="info" %}
25+
### Need help with contract monitoring?
26+
27+
Reach out on the **#api** channel on [Discord](https://stacks.chat/) under the Hiro Developer Tools section.
28+
{% endhint %}
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Create an Alert
2+
3+
Learn how to create an alert to monitor function calls for a contract.
4+
5+
## What you'll learn
6+
7+
- Set up alerts for contract functions
8+
- Configure email and webhook notifications
9+
- Monitor contract usage patterns
10+
11+
## Prerequisites
12+
13+
- Contracts deployed to Stacks mainnet (or use any public contract)
14+
- A Hiro Platform account - [Sign up free](https://platform.hiro.so)
15+
16+
## Set up contract monitoring
17+
18+
{% stepper %}
19+
20+
{% step %}
21+
### Navigate to monitoring
22+
23+
Log into the [Hiro Platform](https://platform.hiro.so) and toggle to the **Monitor** tab.
24+
25+
You can set up alert monitoring for any contracts on mainnet.
26+
{% endstep %}
27+
28+
{% step %}
29+
### Add contract for monitoring
30+
31+
Click **Add contract** to open the contract lookup modal.
32+
33+
You have two options:
34+
- **Manual entry**: Enter the contract principal and contract name
35+
- **Wallet connection**: Connect your wallet to see your deployment history
36+
37+
All contracts deployed to mainnet are public, so you can monitor any of them regardless of who deployed them.
38+
{% endstep %}
39+
40+
{% step %}
41+
### View contract activity
42+
43+
Once added, your contract appears under Contract Monitoring where you can:
44+
- View transaction history
45+
- See pending transactions in the mempool
46+
- Click **Create an alert** to set up specific monitoring
47+
{% endstep %}
48+
49+
{% step %}
50+
### Configure custom alerts
51+
52+
Set up alerts for any contract function calls with specific conditions:
53+
54+
- **Function called**: Alert when a particular function is called
55+
- **With arguments**: Alert only when called with specified argument values
56+
- **By address**: Alert only when called by a specific wallet address
57+
58+
For example, monitor `set-contract-owner`, transfer/mint/burn functions, or any custom functions you've implemented.
59+
{% endstep %}
60+
61+
{% step %}
62+
### Choose notification method
63+
64+
Select how you want to receive alerts:
65+
66+
- **Email notifications**: Receive alerts at your email address
67+
- **Webhook calls**: Send to your API endpoint for custom workflows
68+
69+
You can enable multiple notification methods for the same alert.
70+
{% endstep %}
71+
72+
{% endstepper %}
73+
74+
## Alert payload format
75+
76+
Email notifications come from Hiro Platform `<platform@hiro.so>`.
77+
78+
Webhook payloads follow this structure:
79+
80+
{% tabs %}
81+
{% tab label="JSON" %}
82+
```json
83+
{
84+
"tx_id": "0xa7f511b3f379efef6fe71d0de57712ed13a89c5b6e24dd049eb2cc9a7c24fcb5",
85+
"nonce": 5,
86+
"fee_rate": "250",
87+
"sender_address": "SP2W9QYAHJNS7YTQY9EK2MSTQGX9E2NDMV766JP9Z",
88+
"sponsored": false,
89+
"post_condition_mode": "deny",
90+
"post_conditions": [
91+
{
92+
"type": "stx",
93+
"condition_code": "sent_equal_to",
94+
"amount": "3000000",
95+
"principal": {
96+
"type_id": "principal_standard",
97+
"address": "SP2W9QYAHJNS7YTQY9EK2MSTQGX9E2NDMV766JP9Z"
98+
}
99+
}
100+
],
101+
"anchor_mode": "any",
102+
"tx_status": "pending",
103+
"receipt_time": 1726104636,
104+
"receipt_time_iso": "2024-09-12T01:30:36.000Z",
105+
"tx_type": "contract_call",
106+
"contract_call": {
107+
"contract_id": "SPHW0EJK5KPDMK03ZX792EMP0Q5J3A39ZMTVZZCY.sample-contract",
108+
"function_name": "donate",
109+
"function_signature": "(define-public (donate (amount uint)))",
110+
"function_args": [
111+
{
112+
"hex": "0x01000000000000000000000000002dc6c0",
113+
"repr": "u3000000",
114+
"name": "amount",
115+
"type": "uint"
116+
}
117+
]
118+
}
119+
}
120+
```
121+
{% endtab %}
122+
123+
{% tab label="TypeScript" %}
124+
```ts
125+
interface AlertPayload {
126+
tx_id: string;
127+
nonce: number;
128+
fee_rate: string;
129+
sender_address: string;
130+
sponsored: boolean;
131+
post_condition_mode: string;
132+
post_conditions: PostCondition[];
133+
anchor_mode: string;
134+
tx_status: string;
135+
receipt_time: number;
136+
receipt_time_iso: string;
137+
tx_type: string;
138+
contract_call: ContractCall;
139+
}
140+
141+
interface ContractCall {
142+
contract_id: string;
143+
function_name: string;
144+
function_signature: string;
145+
function_args: FunctionArg[];
146+
}
147+
148+
interface FunctionArg {
149+
hex: string;
150+
repr: string;
151+
name: string;
152+
type: string;
153+
}
154+
155+
interface PostCondition {
156+
type: string;
157+
condition_code: string;
158+
amount: string;
159+
principal: Principal;
160+
}
161+
162+
interface Principal {
163+
type_id: string;
164+
address: string;
165+
}
166+
```
167+
{% endtab %}
168+
{% endtabs %}
169+
170+
{% hint style="info" %}
171+
The `tx_status` will always return "pending" for monitor alerts. Notifications are sent when transactions hit the mempool, not when they're confirmed on the blockchain.
172+
{% endhint %}
173+
174+
## Next steps
175+
176+
- [Hiro Platform](https://platform.hiro.so): Create and manage new webhooks in the Platform.
177+
- [Chainhooks](https://docs.hiro.so/tools/chainhooks): Learn about advanced event monitoring with Chainhook.

0 commit comments

Comments
 (0)