Skip to content

Commit

Permalink
advanced solidity
Browse files Browse the repository at this point in the history
  • Loading branch information
MahithChigurupati committed Dec 16, 2022
1 parent e8b3e9f commit 6ba9e23
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
27 changes: 27 additions & 0 deletions airDrop.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//SPDX-License-Identifier: MIT

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract airDrop is ERC20("AIRDROP","AIR"){

address public creator;

constructor() payable{
creator = msg.sender;
}

modifier onlyOwner(){
require(msg.sender == creator, "Only owner is allowed");
_;
}

function mintNewTokens(address[] memory addresses, uint amount) public onlyOwner{

for(uint i=0;i<addresses.length;i++){
_mint(addresses[i], amount*(10**18));
}

}
}
44 changes: 44 additions & 0 deletions timeToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//SPDX-License-Identifier:MIT

pragma solidity ^0.8.13;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract timedToken is ERC20("TIME TOKEN","TT") {

mapping(address => uint) public lastSpent;
mapping(address => uint) public alreadySpent;
mapping(address => bool) public exclusions;

uint public limitPerDay = 5;

function timedTransfer(address to, uint amount) public {
if(exclusions[msg.sender] == false){
if(block.timestamp - lastSpent[msg.sender] > 1 minutes){
lastSpent[msg.sender] = block.timestamp;
alreadySpent[msg.sender] = amount;
_transfer(msg.sender, to, amount);
}else{
if((alreadySpent[msg.sender] + amount) > limitPerDay){
revert("limit exceeded");
}else{
lastSpent[msg.sender] = block.timestamp;
alreadySpent[msg.sender] += amount;
_transfer(msg.sender, to, amount);
}
}
}else{
_transfer(msg.sender, to, amount);
}

}

function mint() public{
_mint(msg.sender,5);
}

function addToExclusion(address exclude) public{
exclusions[exclude] = !exclusions[exclude];
}

}

0 comments on commit 6ba9e23

Please sign in to comment.