This is a proof of concept transfer-hook program that exibits the power of token extensions for interesting mechanics. It ensures token transfers occur only during market hours and validates the state of token accounts before processing transfers. The program also manages additional account metadata necessary for these operations.
-
Token Transfer Execution:
- Validates that token accounts are in a "transferring" state.
- Ensures transfers only occur during market hours (9:30 AM to 4:00 PM ET, Monday to Friday).
- Executes the token transfer if conditions are met.
-
Account Metadata Management:
- Initializes and updates extra metadata for token accounts.
- Ensures metadata is associated correctly with the respective token mint and authority.
The program includes utility functions to:
- Determine daylight saving time.
- Convert UTC to Eastern Time.
- Find specific weekdays in a given month.
- Check if the current time falls within market hours.
Handles various errors related to transfer operations and market conditions, such as:
- Attempts to transfer outside market hours.
- Invalid seeds or missing signatures.
- Rust and Cargo installed
- Solana CLI and Rust SDK installed
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Build the program using Cargo:
cargo build-bpf
-
Deploy the program to your Solana cluster:
solana program deploy /path/to/program.so
-
Test the program using Solana CLI commands or client-side scripts to ensure it behaves as expected.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.