The Next of Kin smart contract is built on the Stacks blockchain using the Clarity language. This contract allows users to deposit their STX tokens and assign recipients who will receive the tokens in the event of user inactivity for a specified period.
- STX Deposits: Users can deposit their STX tokens into the smart contract securely. The deposited tokens are locked within the contract until they are either claimed by the user or distributed to the recipients.
- Assign Recipients: Users can assign up to 10 recipients, specifying the amount of STX each recipient should receive in the event of inactivity. This ensures that the user's assets are distributed according to their wishes.
- Inactivity Detection: The smart contract utilizes chainhooks to detect user inactivity for a period of one year. Chainhooks are a powerful functionality that target events on the Bitcoin and Stacks blockchains that are crucial to your use case, allowing actions to be triggered based on these events. Learn more about chainhooks.
- Automatic Transfers: Once the inactivity period of one year elapses, the smart contract automatically sends the specified amounts of STX to the assigned recipients. This ensures that the user's assets are managed and transferred without requiring manual intervention.
- Future Feature - STX Staking: In future updates, a feature will be added that allows users to stake their STX in pools. This will enable users to earn staking rewards on their deposited STX while maintaining the core functionality of the Next of Kin smart contract.
- Deposit STX: Users deposit their STX tokens into the smart contract by calling the
depositfunction and specifying the amount to deposit. - Assign Recipients: Users can assign up to 10 recipients by calling the
assign-recipientsfunction and providing the recipient addresses and corresponding amounts. The smart contract stores this information securely. - Inactivity Monitoring: The smart contract continuously monitors user activity. If no activity is detected for a period of one year (52,560 blocks), it triggers the distribution process.
- Trigger Action: Upon detecting inactivity, the smart contract can execute the
check-and-distributefunction, which transfers the specified amounts of STX to the assigned recipients. - Withdraw Funds: Users can withdraw their deposited STX at any time by calling the
withdrawfunction, as long as they have sufficient balance.
- Node.js (v16 or higher)
- Clarinet CLI
- Stacks Wallet
-
Clone the Repository:
git clone https://github.com/walterthesmart/NextOfKin.git cd NextOfKin -
Install Dependencies:
npm install cd "NextOfkin UI" npm install
-
Run Tests:
npm test -
Deploy the Smart Contract:
clarinet deployments apply -p deployments/default.testnet-plan.yaml
deposit(amount: uint)- Deposit STX tokens into the contractwithdraw(amount: uint)- Withdraw STX tokens from your balanceassign-recipients(recipients: list)- Set up to 10 recipients for inheritancecheck-and-distribute(user: principal)- Check inactivity and distribute funds if applicable
get-balance(user: principal)- Get user's deposited balanceget-recipients(user: principal)- Get user's assigned recipientsget-last-activity(user: principal)- Get user's last activity timestamp
-
Start the UI:
cd "NextOfkin UI" npm run dev
-
Connect Your Wallet:
- Open the application in your browser
- Connect your Stacks wallet
- Start depositing and managing your inheritance settings
We welcome contributions! If you would like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature/your-feature). - Commit your changes (
git commit -am 'Add your feature'). - Push to the branch (
git push origin feature/your-feature). - Create a new Pull Request.
This project is licensed under the MIT License.
- Stacks Blockchain for providing the blockchain infrastructure.
- Clarity Language for the smart contract language.
- Chainhook Documentation for the detailed information on using chainhooks.