How tondefi/staking-in-tact works
Main Components
• Smart Contract Logic – This includes the core contract files:
• contract.tact (the designated entry point for the staking contract)
• jetton.tact and message.tact (supporting logic for the jetton tokens and message handling)
• Deployment Mechanism – The deployment scripts and configuration files:
• sources/contract.deploy.Staking.ts (handles deploying the contract by invoking the Init() function)
• tact.config.json (ensures the correct configuration if the entry point file is renamed)
• package.json scripts (e.g., “yarn deploy”)
• Operational Scripts – Scripts facilitating runtime operations and interactions:
• sources/1_Transfer_Stake.ts (script that triggers a stake transfer from a jetton wallet to the staking contract)
• sources/2_TransferURL.ts (generates a URL for users to stake jettons, referring to a WalletV4 address)
• sources/utils/ (helper functions like deploy.ts, jetton-helpers.ts, and print.ts, which support deployment and contract interaction)
• Testing Suite – Automated testing is covered by:
• sources/contract.spec.ts (defines test cases and scenarios to ensure the contract behaves correctly)
• jest.config.js (configuration for running tests)
• Build Artifacts & Outputs – The compiled output artifacts and ABIs include:
• Multiple files in sources/output (ABI files, code (in various formats such as .boc, .fc, .fif), headers, metadata, etc. for different contract sample variants such as SampleJetton_JettonDefaultWallet, SampleJetton_SampleJetton, and SampleJetton_StakingContract)
Relationships and Interactions
• The deployment system (via contract.deploy.Staking.ts and tact.config.json) interacts directly with the smart contract logic (contract.tact) to package and deploy the contract on the blockchain.
• The operational scripts (1_Transfer_Stake.ts, 2_TransferURL.ts) provide an interface for users and developers to interact with the deployed contract.
• The tests (contract.spec.ts) run against the contract code ensuring that all behaviors (like staking transfers) are correctly implemented.
• Utilities in the sources/utils directory assist both deployment and interactions, abstracting common functions.
• Build, configuration, and package management (via package.json, tsconfig.json, jest.config.js, etc.) orchestrate the overall development lifecycle – from building, testing, to deploying.
Architectural Patterns & Design Principles
• Separation of Concerns: The project clearly separates contract logic (Tact files) from operational scripts (TypeScript files) and testing scripts.
• Build and Deployment Workflow: There is a defined workflow – tests with yarn test, build with yarn build, deployment with yarn deploy – which is supported by configuration files and utilities.
• Modular Utilities: Helper files under sources/utils encapsulate common operational tasks.
• Output Artifacts: The output directory clearly distinguishes the generated artifacts from the source code, facilitating versioning and auditability.
• Mention any external services (for instance, if the contract is to be deployed to a blockchain network such as TON, you might note “Blockchain Node” or “TON Network API” to represent where the contract would run).