https://github.com/whoabuddy/key-health-check
Simple Clarity contract that tracks the last block height a principal checked in at.
https://github.com/whoabuddy/key-health-check
Last synced: 3 months ago
JSON representation
Simple Clarity contract that tracks the last block height a principal checked in at.
- Host: GitHub
- URL: https://github.com/whoabuddy/key-health-check
- Owner: whoabuddy
- Created: 2022-01-28T21:49:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-28T22:06:14.000Z (over 3 years ago)
- Last Synced: 2025-02-07T17:35:26.223Z (4 months ago)
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Key Health Check
This is a simple Clarity smart contract that runs on the [Stacks blockchain](https://stacks.co).
It contains a map that stores a user's principal and the last block height checked in at by calling the contract.
There are two functions:
- `check-in`: public function that takes the `contract-caller` address and stores it in the map along with the current block height
- `last-checked`: read-only function that requires a principal as input, then returns either the last block height they checked in or an error if not found## Testing
Given the simplicity of this contract I tested it via Clarinet Console, sample commands below:
```
::advance_chain_tip 5
(contract-call? .key-health-check check-in)
(contract-call? .key-health-check last-checked 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM)
(contract-call? .key-health-check last-checked 'ST2NEB84ASENDXKYGJPQW86YXQCEFEX2ZQPG87ND)
::advance_chain_tip 95
(contract-call? .key-health-check check-in)
(contract-call? .key-health-check last-checked 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM)
```