Overview
A comprehensive token project template with four production-grade contracts covering the full token lifecycle: creation, distribution via vesting, yield via staking, and secure management via multisig.| Difficulty | Intermediate |
| Category | Token |
| Chains | Ethereum |
| Services | None |
| License | Apache-2.0 |
Quick Start
Generated Files
my-token
dokrypt.yaml
foundry.toml
README.md
contracts
token
ManagedToken.sol
vesting
VestingSchedule.sol
staking
StakeRewards.sol
multisig
MultiSig.sol
test
token
ManagedToken.t.sol
vesting
VestingSchedule.t.sol
staking
StakeRewards.t.sol
multisig
MultiSig.t.sol
scripts
deploy-token.js
setup-vesting.js
Contracts
ManagedToken.sol
Full-featured ERC-20 with owner-controlled minting, burning, and emergency pause. Constructor:| Function | Access | Description |
|---|---|---|
transfer(to, amount) | Public | Transfer tokens (reverts when paused) |
approve(spender, amount) | Public | Approve spending |
transferFrom(from, to, amount) | Public | Transfer on behalf |
mint(to, amount) | Owner | Mint new tokens |
burn(amount) | Public | Burn your own tokens |
pause() | Owner | Pause all transfers |
unpause() | Owner | Resume transfers |
transferOwnership(newOwner) | Owner | Transfer ownership |
Transfer, Approval, Paused, Unpaused, OwnershipTransferred
VestingSchedule.sol
Linear token vesting with configurable cliff and duration. Constructor:| Function | Access | Description |
|---|---|---|
createSchedule(beneficiary, amount, start, cliffDuration, duration) | Owner | Create vesting schedule |
release(scheduleId) | Public | Release vested tokens to beneficiary |
revoke(scheduleId) | Owner | Cancel schedule, return unvested tokens |
releasableAmount(scheduleId) | View | Calculate currently vested amount |
- Before cliff: 0 tokens are vested
- After cliff: tokens vest linearly over the remaining duration
- Formula:
vestedAmount = totalAmount * (currentTime - start) / duration
ScheduleCreated, TokensReleased, ScheduleRevoked
StakeRewards.sol
Synthetix-style proportional staking rewards. Users stake tokens and earn rewards proportional to their share of the total stake. Constructor:| Function | Access | Description |
|---|---|---|
stake(amount) | Public | Stake tokens |
withdraw(amount) | Public | Unstake tokens |
getReward() / claimReward() | Public | Claim accumulated rewards |
exit() | Public | Withdraw all + claim rewards |
setRewardsDuration(duration) | Owner | Set reward period length |
notifyRewardAmount(amount) | Owner | Start/refill reward distribution |
earned(account) | View | Check pending rewards |
rewardPerToken() | View | Current reward per staked token |
rewardRate = rewardAmount / durationrewardPerToken += rewardRate * timeDelta / totalStakedearned = stakedBalance * (rewardPerToken - userPaidPerToken) + storedRewards
Staked, Withdrawn, RewardPaid, RewardsDurationUpdated
MultiSig.sol
M-of-N multisignature wallet for secure fund management. Constructor:_owners: Array of owner addresses_required: Minimum confirmations needed to execute
| Function | Access | Description |
|---|---|---|
submitTransaction(to, value, data) | Owner | Submit a new transaction |
confirmTransaction(txId) | Owner | Confirm a pending transaction |
revokeConfirmation(txId) | Owner | Revoke your confirmation |
executeTransaction(txId) | Owner | Execute if enough confirmations |
getTransactionCount() | View | Total transaction count |
getTransaction(txId) | View | Get transaction details |
Deposit, Submission, Confirmation, Revocation, Execution, ExecutionFailure
The wallet accepts ETH via the receive() function, emitting a Deposit event.
Deployment
Deploy Token
| Variable | Default | Description |
|---|---|---|
TOKEN_NAME | — | Token name |
TOKEN_SYMBOL | — | Token symbol |
INITIAL_SUPPLY | — | Initial supply (whole tokens) |
RPC_URL | http://localhost:8545 | Chain RPC |
PRIVATE_KEY | — | Deployer private key |