From 399d25fc0bb329be6b83877a84b6f6e1b8da8729 Mon Sep 17 00:00:00 2001 From: nprimo Date: Thu, 1 Feb 2024 17:42:05 +0100 Subject: [PATCH] feat(usable-tokens): add details to subject --- subjects/blockchain/usable-token/README.md | 35 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/subjects/blockchain/usable-token/README.md b/subjects/blockchain/usable-token/README.md index d9753f6a..92abf82b 100644 --- a/subjects/blockchain/usable-token/README.md +++ b/subjects/blockchain/usable-token/README.md @@ -2,10 +2,37 @@ ### Instructions -- Create a Smart Contract named `UsableToken` -- Like MinimalToken, its constructor takes as parameter an amount that is given initially to the deployer. -- Create a function `approve(address,uint)` that allows the owner of the token to approve a spender to spend a certain amount of tokens. -- Create a function `allowance(address,uint)` that returns the amount of tokens that a spender can spend on behalf of the owner. +- Complete the following Smart Contract named `UsableToken` +- Like `MinimalToken`, its constructor takes as parameter an amount that is + given initially to the deployer account. +- Create a function `transfer(address, uint)` that allows the owner to transfer + a certain amount of tokens to the specified address. +- Create a function `approve(address, uint)` that allows the owner of the token + to approve a spender to spend a certain amount of tokens. +- The `allowance` states should keep track of the amount of tokens that a + spender can spend on behalf of the owner. + +```js +contract UsableToken { + ... public accounts; + ... public allowance; + + constructor(uint256 initialNumber) { + ... + } + + function transfer(address to, uint256 amount) public { + ... + } + + function approve(address spender, uint256 amount) public { + ... + } + + function transferFrom(address from, address to, uint256 amount) public { + } +} +``` ### Notions