alert-contract 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/contracts/main/AlertContractV1.sol +41 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# EVM Observability SDK
|
|
2
|
+
|
|
3
|
+
Lightweight, zero-dependency **on-chain observability SDK** for EVM smart contracts.
|
|
4
|
+
|
|
5
|
+
This SDK provides a simple and gas-efficient way to emit **structured telemetry events**
|
|
6
|
+
from smart contracts, enabling off-chain analytics, tracing, monitoring, and product metrics
|
|
7
|
+
— without changing business logic.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 🚀 Installation
|
|
12
|
+
|
|
13
|
+
Install via npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @smart-alert/evm-observability
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## ✨ Key Features
|
|
22
|
+
|
|
23
|
+
- 📡 Function call tracing (who, what, where)
|
|
24
|
+
- 📊 Business metrics emitted directly from contracts
|
|
25
|
+
- 🧩 Zero runtime dependencies
|
|
26
|
+
- ⚡ No external calls, no shared state
|
|
27
|
+
- 🛠 Works with any EVM-compatible chain
|
|
28
|
+
- 🧠 Contract-agnostic off-chain analytics
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 📦 What This SDK Is (and Is Not)
|
|
33
|
+
|
|
34
|
+
### ✅ This SDK **IS**
|
|
35
|
+
- A **Solidity compile-time SDK**
|
|
36
|
+
- A set of **standardized events**
|
|
37
|
+
- A reusable **abstract contract**
|
|
38
|
+
- A stable **on-chain telemetry schema**
|
|
39
|
+
|
|
40
|
+
### ❌ This SDK is **NOT**
|
|
41
|
+
- A deployed central contract
|
|
42
|
+
- A runtime dependency
|
|
43
|
+
- A protocol with shared state
|
|
44
|
+
- A replacement for business events like `Transfer`
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🏗 Architecture Overview
|
|
49
|
+
|
|
50
|
+
Smart Contract Architecture
|
|
51
|
+
===========================
|
|
52
|
+
|
|
53
|
+
```mermaid
|
|
54
|
+
flowchart TD
|
|
55
|
+
A["Your Smart Contract (Vault, AMM, etc)"]
|
|
56
|
+
B["Observability.sol (SDK) - ObsCall, ObsMetric"]
|
|
57
|
+
C["Blockchain Logs"]
|
|
58
|
+
D["Off-chain SDK / Indexer / Analytics"]
|
|
59
|
+
|
|
60
|
+
A --> B
|
|
61
|
+
B --> C
|
|
62
|
+
C --> D
|
|
63
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
pragma solidity ^0.8.20;
|
|
3
|
+
|
|
4
|
+
abstract contract Observability {
|
|
5
|
+
event ObsCall(
|
|
6
|
+
address indexed contractAddress,
|
|
7
|
+
bytes4 indexed selector,
|
|
8
|
+
address indexed caller,
|
|
9
|
+
uint256 gasLeft
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
event ObsMetric(
|
|
13
|
+
address indexed contractAddress,
|
|
14
|
+
bytes32 indexed name,
|
|
15
|
+
uint256 value
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
event ObsError(
|
|
19
|
+
address indexed contractAddress,
|
|
20
|
+
bytes4 indexed selector,
|
|
21
|
+
bytes reason
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
modifier observe() {
|
|
25
|
+
emit ObsCall(
|
|
26
|
+
address(this),
|
|
27
|
+
msg.sig,
|
|
28
|
+
msg.sender,
|
|
29
|
+
gasleft()
|
|
30
|
+
);
|
|
31
|
+
_;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function _metric(bytes32 name, uint256 value) internal {
|
|
35
|
+
emit ObsMetric(address(this), name, value);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _error(bytes memory reason) internal {
|
|
39
|
+
emit ObsError(address(this), msg.sig, reason);
|
|
40
|
+
}
|
|
41
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "alert-contract",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "EVM on-chain observability SDK for Solidity",
|
|
5
|
+
"main": "contracts/main/AlertContractV1.sol",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"compile": "npx hardhat compile --show-stack-traces",
|
|
8
|
+
"test": "npx hardhat test"
|
|
9
|
+
},
|
|
10
|
+
"keywords": ["solidity", "sdk", "evm", "observability", "metrics", "smart-alert"],
|
|
11
|
+
"author": "alkesproject@gmail.com",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"files": [
|
|
14
|
+
"contracts/main"
|
|
15
|
+
],
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
|
|
18
|
+
"@nomicfoundation/hardhat-toolbox": "^4.0.0",
|
|
19
|
+
"@openzeppelin/contracts": "^4.9.3",
|
|
20
|
+
"@openzeppelin/hardhat-upgrades": "^3.0.5",
|
|
21
|
+
"@types/luxon": "^3.3.1",
|
|
22
|
+
"hardhat": "^2.19.4",
|
|
23
|
+
"hardhat-gas-reporter": "^1.0.9"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@nomicfoundation/hardhat-verify": "^2.1.0",
|
|
27
|
+
"dotenv": "^16.3.1",
|
|
28
|
+
"luxon": "^3.3.0"
|
|
29
|
+
}
|
|
30
|
+
}
|