Created
August 30, 2022 17:33
-
-
Save AdityaEXP/3d382dae8fafad082f2d8c1365271590 to your computer and use it in GitHub Desktop.
A tipper contract used by a tg bot with tax included while transfering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
total_balance: uint256 | |
tax_address: address | |
tax: uint256 | |
event Tip: | |
sender: indexed(address) | |
to: indexed(address) | |
amount: uint256 | |
tax: uint256 | |
@external | |
def __init__(tax_address: address, tax: uint256): | |
self.total_balance = 0 | |
self.tax_address = tax_address | |
self.tax = tax | |
@external | |
@view | |
def getTaxWallet() -> address: | |
return self.tax_address | |
@external | |
@view | |
def getTotalBalance() -> uint256: | |
return self.total_balance | |
@external | |
@payable | |
def sendETH(to_address: address): | |
fee: uint256 = msg.value * self.tax / 100 | |
send(self.tax_address, fee) | |
send(to_address, msg.value - fee) | |
log Tip(msg.sender, to_address, msg.value, fee) | |
self.total_balance+=msg.value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment