# Erc20 front end problem

**URL:** <https://forum.dfinity.org/t/erc20-front-end-problem/5742>\
**Category:** Developers\
**Tags:** Functional-Programming\
**Created:** [July 6, 2021, 2:25pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742 "2021-07-06T14:25:35Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 6, 2021, 2:25pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/1 "2021-07-06T14:25:35Z")

</div>

I get the code for the erc20 token and deploy it. It runs as expected. Then I create a front end for the coding. In the front end, I get the total supply, name, decimal output in the front end. I get the output for the transfer function in an erc20 in the command line, but it doesn’t work in the front end. I listed the code below. Can anyone help me?

motoko code:

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/1/119bbb334bf60ef90bc125adf943328b7a82e3d7.png)

Front end code:  
 ![4bNqF0FoTV](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/1/18c2a1a8aba121c51c75c691dc6d5a7a51a56627.png)

 ![zGWfUeWLtc](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/2/2245966d683a29a8976712bf86e729cb3c4368ab.png)

It doesn’t work in the front end. But in the command line, it works.

---

<div class="post-metadata">

**Author:** ![stephenandrews](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/stephenandrews/32/1803_2.png) [@stephenandrews](https://forum.dfinity.org/u/stephenandrews)\
**Post date:** [July 6, 2021, 2:45pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/2 "2021-07-06T14:45:42Z")

</div>

val needs to be a number

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 6, 2021, 4:08pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/3 "2021-07-06T16:08:45Z")

</div>

I already put **type Number=Nat;** before the transfer function. I got the result in the command line but I don’t get the output in the front end. What mistake have I done?

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 6, 2021, 4:09pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/4 "2021-07-06T16:09:54Z")

</div>

Can you explain clearly? What I have to change?

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 6, 2021, 5:07pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/5 "2021-07-06T17:07:44Z")

</div>

.value from an input is going to be a string. You’ll need to pass

```auto
Number(val)

```

![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/e/e56609404da1fce8ccf6f537a50547b06570562f.png)

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 6, 2021, 6:12pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/6 "2021-07-06T18:12:53Z")

</div>

I did what you said, but the output returns boolean false. It doesn’t transfer token  
 ![mYyizKMS3t](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/2/27dc653beef49c1a2e6a489e037b630636472081.png)  
code:

 ![Nr9ahV2fqo](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/6/6a3a1d68e1f50390fbade30f2b7eec86d6cb8288.png)  
What I have to change?please explain

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 6, 2021, 6:18pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/7 "2021-07-06T18:18:26Z")

</div>

What I have to change?

---

<div class="post-metadata">

**Author:** ![stephenandrews](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/stephenandrews/32/1803_2.png) [@stephenandrews](https://forum.dfinity.org/u/stephenandrews)\
**Post date:** [July 6, 2021, 7:52pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/8 "2021-07-06T19:52:25Z")

</div>

Maybe return an error at the different parts in the code to figure out why it’s return false? Looks like from\_balance is either null (ie no balance) or not enough. Remeber you are using the caller’s balance

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 6, 2021, 8:02pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/9 "2021-07-06T20:02:13Z")

</div>

That makes sense. to @stephenandrews point - the JavaScript agent makes calls as an AnonymousAgent by default. You’ll need an identity strategy for your frontend to manage who can have a balance

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 7, 2021, 4:19am UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/10 "2021-07-07T04:19:46Z")

</div>

I have balance transfer function is worked in command line

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 7, 2021, 4:20am UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/11 "2021-07-07T04:20:22Z")

</div>

What I have to change ?Please help me

---

<div class="post-metadata">

**Author:** ![stephenandrews](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/stephenandrews/32/1803_2.png) [@stephenandrews](https://forum.dfinity.org/u/stephenandrews)\
**Post date:** [July 7, 2021, 4:23am UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/12 "2021-07-07T04:23:53Z")

</div>

You need authentication client side so that the canister knows who is calling and what balance to transfer from.

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 7, 2021, 5:43am UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/13 "2021-07-07T05:43:03Z")

</div>

In the client side ,How to get the information of caller information. Can you give ma a one example related to that

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 7, 2021, 5:47am UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/14 "2021-07-07T05:47:37Z")

</div>

The most ready-made solution right now is internet identity. Here’s an example application I put together as a reference

> **[krpeacock/auth-client-demo](https://github.com/krpeacock/auth-client-demo)**
>
> Example demo of how to use https://www.npmjs.com/package/@dfinity/auth-client to make authenticated calls to an IC app - krpeacock/auth-client-demo

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 7, 2021, 12:40pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/15 "2021-07-07T12:40:04Z")

</div>

Thank you . I will check

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 9, 2021, 9:20am UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/16 "2021-07-09T09:20:29Z")

</div>

How to install the dependencies for this project? I clone this project. Then what I have to do?

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 9, 2021, 4:12pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/17 "2021-07-09T16:12:42Z")

</div>

```auto
npm install
dfx start --clean --background
dfx deploy
npm start

```

Should get you up and running

---

<div class="post-metadata">

**Author:** ![harish007](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@harish007](https://forum.dfinity.org/u/harish007)\
**Post date:** [July 9, 2021, 5:05pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/18 "2021-07-09T17:05:10Z")

</div>

I put npm install, then I put npm start, It shows you are not downloaded typescript, then I install typescript also I installed @dfinity/candid,@dfinity/identity,@dfinity/authentication  
Then it shows an error like this:  
 ![dCvde0Kay3](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/5/52d812c18f8c6d5addf0b647cdb7617f42748200.png)

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 9, 2021, 5:07pm UTC](https://forum.dfinity.org/t/erc20-front-end-problem/5742/19 "2021-07-09T17:07:48Z")

</div>

ah yeah. You can create a file named `.env` and add

```auto
CANISTER_ID=<whoami_canister_id>

```

I should add these steps to the readme
