The CyptoKid
contract allows the creation of accounts for children's education savings. The contract owner can add kids' accounts, deposit funds into the accounts, and allow the kids to withdraw funds after a specific release date. Each kid account is associated with an address, first name, last name, release date, and amount.
The following events are emitted by the contract:
Deposit(address sender, uint amount, uint time)
: Triggered when funds are deposited into a kid's account.Withdrawal(address receiver, uint amount, uint time)
: Triggered when funds are withdrawn from a kid's account.
owner
(address): The address of the contract owner.kids
(array of Kid): An array that stores information about each kid account.
Kid
: Stores information about a kid's account, including the wallet address, first name, last name, release date, amount, and withdrawal status.
The constructor sets the contract owner to the address of the deployer.
onlyOwner
: Ensures that only the contract owner can execute the function.validAddress
: Checks if the provided address is valid (not the zero address).
The CyptoKid
contract provides the following functions:
addKid(address payable _walletAddress, string memory _firstName, string memory _lastName) → public onlyOwner validAddress(_walletAddress)
Adds a new kid's account to the contract.
_walletAddress
(address payable): The wallet address associated with the kid's account._firstName
(string): The first name of the kid._lastName
(string): The last name of the kid.
Deposits funds into a kid's account.
_walletAddress
(address): The wallet address associated with the kid's account.
Returns the current balance of the caller's kid account.
Checks if a kid's account is eligible for fund withdrawal based on the release date.
_walletAddress
(address): The wallet address associated with the kid's account.
bool
:true
if the kid's account is eligible for withdrawal,false
otherwise.
Withdraws funds from a kid's account.
_walletAddress
(address payable): The wallet address associated with the kid's account.
- Deploy the
CyptoKid
contract. - Call the
addKid
function to create a new kid's account, providing the kid's wallet address, first name, and last name. - Deposit funds into a kid's account using the
deposit
function, specifying the kid's wallet address. - Check the balance of a kid's account using the
balance
function. - Verify if a kid's account is eligible for withdrawal using the
availableToWithdraw
function. - Withdraw funds from a kid's account using the
withdraw
function, providing the kid's wallet address.
This code is licensed under the MIT License.