2.3 KiB
2.3 KiB
Overview
The IGreeter interface defines a standardized contract for managing dynamic greeting messages with advanced authorization and security features. It provides methods for retrieving, updating, and controlling access to greeting modifications.
Interface
| Function | Visibility | Parameters | Returns | Description |
|---|---|---|---|---|
getGreeting() |
External View | None | string memory |
Retrieve current greeting |
updateGreeting() |
External | newGreeting: string, nonce: uint256, signature: bytes |
None | Update greeting with optional signature authorization |
isAuthorizedGreeter() |
External View | account: address |
bool |
Check greeting modification permissions |
getDeploymentTimestamp() |
External View | None | uint256 |
Get contract deployment timestamp |
Events
GreetingChanged(address indexed updater, string newGreeting): Emitted when a greeting is successfully modified, tracking the updater and new message.
Storage Layout
- Greeting string (private/internal)
- Deployment timestamp
- Optional authorization mapping or access control mechanism
Access Control
- Implements flexible authorization via
isAuthorizedGreeter() - Supports optional signature-based authorization
- Prevents unauthorized greeting modifications
- Custom error
UnauthorizedGreetingModificationfor access control failures
Security Considerations
- Prevents replay attacks using nonce parameter
- Optional cryptographic signature verification
- Immutable deployment timestamp tracking
- Explicit error handling for unauthorized access attempts
Deployment
ChunkNet Devnet Configuration
- RPC URL: https://rpc.chunknet.org
- Chain ID: 214562
- Recommended Deployment Steps:
- Set environment variable
CHUNK_CHAIN_RPC_URL - Use appropriate network configuration
- Validate contract bytecode
- Deploy with proper constructor parameters
- Set environment variable
Deployment Script Example
bash
forge create --rpc-url $CHUNK_CHAIN_RPC_URL
--private-key $DEPLOYER_PRIVATE_KEY
contracts/Greeter.sol:Greeter
Testing
- Unit test greeting retrieval
- Verify authorization mechanisms
- Test signature validation
- Check nonce replay protection
- Validate event emissions
- Simulate unauthorized modification attempts