Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
crosschainer authored Aug 17, 2024
1 parent de010c1 commit 8c6ca81
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ def token_contract():
owner.set(ctx.caller)

@export
def balance_of(wallet_id):
return balances[wallet_id]

def approve(amount: float, to: str):
assert amount > 0, 'Cannot send negative balances.'
balances[ctx.caller, to] += amount

@export
def transfer(to, amount):
sender_balance = balances[ctx.caller]
def transfer_from(amount: float, to: str, main_account: str):
assert amount > 0, 'Cannot send negative balances.'
assert balances[main_account, ctx.caller] >= amount, f'Not enough coins approved to send. You have {balances[main_account, ctx.caller]} and are trying to spend {amount}'
assert balances[main_account] >= amount, 'Not enough coins to send.'

balances[main_account, ctx.caller] -= amount
balances[main_account] -= amount
balances[to] += amount

assert sender_balance >= 0, "Sender balance must be non-negative!!!"

@export
def transfer(amount: float, to: str):
assert amount > 0, 'Cannot send negative balances.'
assert balances[ctx.caller] >= amount, 'Not enough coins to send.'

balances[ctx.caller] -= amount
balances[to] += amount

Expand Down

0 comments on commit 8c6ca81

Please sign in to comment.