This project allows users to buy a cute cat from our branches and mint NFT for buying a cat. The NFT will be used to track the cat info and all related data for a particular cat corresponding to their token ids. Cat owners can also visit any partner shop for vet checkup and makes payment in KittyToken. Cat Owner can also take insurance policy for their cat and all the payment will be done in KittyToken. The KittyToken is ERC20 token pegged with the USDC and all data of price feed are come from the Chainlink Data Feeds
. Kitty Owner can also Bridge their NFT from one chain to another chain via Chainlink CCIP
.
The codebase is broken up into 6 contracts:
KittyConnect.sol
KittyInsurance.sol
KittyToken.sol
KittyBridge.sol
KittyInsuranceProvider.sol
Ownable.sol
This contract allows users to buy a cute cat from our branches and mint NFT for buying a cat. The NFT will be used to track the cat info and all related data for a particular cat corresponding to their token ids. Cat owners can also visit any partner shop for vet checkup and makes payment in KittyToken (the price of the token is same as USDC).
This contract allows users to pay his premium in KittyToken to the policy provider and also claim the insurance by any shop partner in KittyToken. The insurance will be valid for either 1 year or 6 month as per the user choice.
This contract allows users to buy KittyToken which pegged with the USDC and all the data feeds of prices are come from the the Chainlink Data Feeds
.
This contract allows users to bridge their Kitty NFT from one chain to another chain via Chainlink CCIP
.
This contract allows policy provider to deploy the insurance policy for the users. The policy parameter will be decided between the policy provider and the cat Owner (for example: coverage amount, premium amount, Time(1 year or 6 month), etc.). By the contract, policy provider can also mark the insurance complete when the insurance time completed with all the premium amount paid by the user.
This contract allows the owner to transfer the ownership of the contract to another address.
- Cat Owner
- User who buy the cat from our branches and mint NFT for buying a cat.
- Shop Partner
- Shop partner provide services to the cat owner to buy can and make payment in KittyToken.
- Insurance Policy Provider
- Policy provider provides insurance policy to the cat owner and all the payment will be done in KittyToken.
- KittyConnect Owner
- Owner of the contract who can transfer the ownership of the contract to another address.
- git
- You'll know you did it right if you can run
git --version
and you see a response likegit version x.x.x
- You'll know you did it right if you can run
- foundry
- You'll know you did it right if you can run
forge --version
and you see a response likeforge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
- You'll know you did it right if you can run
git clone https://github.com/shikhar229169/KittyConnect.git
cd KittyConnect
forge build
OR
forge install
forge test
forge coverage
forge compile
$ forge --help
$ anvil --help
$ cast --help
forge script script/DeployKittyConnect.s.sol:DeployKittyConnect --fork-url $RPC_URL --private-key $PRIVATE_KEY --verify --broadcast
forge script script/Interactions.s.sol:BuyCat --fork-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
forge script script/Interactions.s.sol:BridgeNFT --fork-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
- first User will buy the Cat from our branches and mint NFT for buying a cat. By calling the function by Shop patners, this NFT will track all the data related to the cat :
function mintCatToNewOwner(
address catOwner,
string memory catIpfsHash,
string memory catName,
string memory breed,
uint256 dob
) external onlyShopPartner;
- User can buy the KittyToken from the KittyToken contract by calling the function :
function mintKittyTokenForEth() external payable;
- User can bridge Kitty NFT from one chain to another chain by calling this function from KittyConnect contract:
function bridgeNftToAnotherChain(uint64 destChainSelector, address destChainBridge, uint256 tokenId) external;
- User can take insurance policy for their cat by this function from KittyInsuranceProvider contract call by the policy provider:
function provideInsurance(
address _kittyOwner,
uint256 _premiumAmount,
uint256 _coverageAmount,
bool _isOneYear,
address _tokenAddress,
uint256 _tokenId
) external onlyPolicyHolder;
- User can pay the premium amount in KittyToken by calling this function from KittyInsurance contract:
// if user policy is for one year
function payPremiumForOneYearPolicy(uint256 amount) external onlyKittyOwner PremiumPaid oneYear;
// OR
// if user policy is for six month
function payPremiumForSixMonthPolicy(uint256 amount) external onlyKittyOwner PremiumPaid sixMonths
- User can claim the insurance by this function from KittyInsurance contract call by the shop partner:
function claim() external onlyShopPartner notExpired notClaimed;
- User can sell their cat to other user by calling this function from KittyConnect contract:
function transferFrom(address currCatOwner, address newOwner, uint256 tokenId) public override onlyShopPartner;
// Same as transferFrom but with additional data field
function safeTransferFrom(address currCatOwner, address newOwner, uint256 tokenId, bytes memory data) public override onlyShopPartner;
- User can visit any partner shop for vet checkup and makes payment in KittyToken by this function from KittyConnect contract call by the shop partner:
function redeemTokensForVetVisit(address catOwner, uint256 tokenId, uint256 amount, string memory remarks) external onlyShopPartner;
- These are the getter functions of KittyConnect contract:
function tokenURI(uint256 tokenId) public view override returns (string memory);
function getCatAge(uint256 tokenId) external view returns (uint256);
function getTokenCounter() external view returns (uint256);
function getKittyConnectOwner() external view returns (address);
function getKittyConnectOwner() external view returns (address);
function getAllKittyShops() external view returns (address[] memory);
function getKittyShopAtIdx(uint256 idx) external view returns (address);
function getIsKittyPartnerShop(address partnerShop) external view returns (bool);
function getKittyToken() external view returns (address);
function getCatInfo(uint256 tokenId) external view returns (CatInfo memory);
function getCatsTokenIdOwnedBy(address user) external view returns (uint256[] memory);
- These are the getter functions of KittyToken contract:
function getEthUsdPriceFeed() external view returns (address);
function getKittyConnectAddr() external view returns (address);
- These are the getter functions of KittyBridge contract:
function getKittyConnectAddr() external view returns (address);
function getGaslimit() external view returns (uint256);
function getLinkToken() external view returns (address);
- These are the getter functions of KittyInsurance contract:
function getExpirationTimestamp() external view returns (uint256);
function getTotalPremiumPaidByOwner() external view returns (uint256);
function getNetPremiumToBepaid() external view returns (uint256);
function getPolicyHolder() external view returns (address);
function getKittyConnect() external view returns (address);
function getKittyToken() external view returns (address);
function getKittyOwner() external view returns (address);
function getIsOneYear() external view returns (bool);
function getPremiumAmount() external view returns (uint256);
function getCoverageAmount() external view returns (uint256);
function getIsClaimed() external view returns (bool);
function getTokenId() external view returns (uint256);
- These are the getter functions of KittyInsuranceProvider contract:
function getTokenIdToInsuranceContract(uint256 tokenId) external view returns (address);
function getPolicyHolder() external view returns (address);
function getKittyConnect() external view returns (address);
function getKittyToken() external view returns (address);