Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions batch-payment/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

settings/Mainnet.toml
settings/Testnet.toml
history.txt
4 changes: 4 additions & 0 deletions batch-payment/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

{
"deno.enable": true,
}
18 changes: 18 additions & 0 deletions batch-payment/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

{
"version": "2.0.0",
"tasks": [
{
"label": "check contracts",
"group": "test",
"type": "shell",
"command": "clarinet check"
},
{
"label": "test contracts",
"group": "test",
"type": "shell",
"command": "clarinet test"
}
]
}
11 changes: 11 additions & 0 deletions batch-payment/Clarinet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[project]
name = "batch-payment"
authors = []
description = ""
telemetry = true
requirements = []
analysis = ["check_checker"]
costs_version = 2
[contracts.batch-transfer]
path = "contracts/batch-transfer.clar"
depends_on = []
119 changes: 119 additions & 0 deletions batch-payment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Batch Transfer Smart Contract

A secure and efficient Clarity smart contract for executing batch token transfers on the Stacks blockchain with comprehensive transaction monitoring, security controls, and administrative features.

## Overview

This smart contract enables efficient batch transfers of tokens while implementing robust security measures, rate limiting, and comprehensive transaction tracking. It's designed for scenarios requiring high-volume transfers while maintaining security and transparency.

### Key Benefits
- Reduced gas costs through batch processing
- Built-in security controls and rate limiting
- Comprehensive transaction history
- Flexible administrative controls
- Emergency safety mechanisms

## Features

### Core Functionality
1. **Batch Transfers**
- Process up to 50 transfers in a single transaction
- Automatic fee calculation and distribution
- Transaction memo support

2. **Security Controls**
- Address blacklisting
- Rate limiting
- Transaction nonce validation
- Privileged address management

3. **Transaction Monitoring**
- Detailed transaction history
- Event logging
- Transfer velocity tracking

4. **Administrative Functions**
- Contract pause/resume
- Fee rate adjustment
- Treasury address management
- Emergency fund recovery

## Security Measures

1. **Rate Limiting**
- Maximum batch size: 50 transfers
- Daily transaction limits
- Configurable rate limiting per address

2. **Access Controls**
- Administrator-only functions
- Blacklist functionality
- Privileged address system

3. **Transaction Safety**
- Nonce-based replay protection
- Balance verification
- Fee validation

4. **Emergency Controls**
- Contract pause mechanism
- Emergency withdrawal function
- Stuck token recovery

## Contract Configuration

### System Constants
```clarity
MAXIMUM-BATCH-TRANSFERS: u50
MINIMUM-TRANSFER-THRESHOLD: u1
DAILY-RATE-LIMIT-BLOCKS: u144
MAXIMUM-MEMO-CHARACTERS: u50
MAXIMUM-FEE-BASIS-POINTS: u100
```

### Default Settings
- Default fee rate: 0.5% (5 basis points)
- Contract operational status: Active
- Treasury wallet: Contract administrator

## Security Considerations

1. **Rate Limiting**
- Monitor transfer velocity
- Adjust DAILY_RATE_LIMIT_BLOCKS if needed
- Review privileged addresses regularly

2. **Access Control**
- Secure administrator private key
- Regular review of restricted addresses
- Monitor privileged address usage

3. **Transaction Safety**
- Verify nonce uniqueness
- Check recipient addresses
- Validate transfer amounts

## Error Codes

| Code | Description |
|------|-------------|
| u1 | Unauthorized Access |
| u2 | Invalid Transfer Amount |
| u3 | Transfer Execution Failed |
| u4 | Insufficient Token Balance |
| u5 | Invalid Recipient Address |
| u6 | Batch Size Exceeded |
| u7 | Address Blacklisted |
| u8 | Transfer Rate Limit Exceeded |
| u9 | Contract Paused |
| u10 | Invalid Memo Length |
| u11 | Duplicate Transaction |
| u12 | Token Recovery Failed |


## Contributing

Contributions are welcome! Please follow these steps:
1. Fork the repository
2. Create a feature branch
3. Submit a pull request
Loading