Skip to content
This repository has been archived by the owner on Mar 16, 2023. It is now read-only.

ZkAsset not properly reporting information on linked token #516

Open
TomAFrench opened this issue May 4, 2020 · 2 comments
Open

ZkAsset not properly reporting information on linked token #516

TomAFrench opened this issue May 4, 2020 · 2 comments

Comments

@TomAFrench
Copy link
Member

Expected Behaviour

The token property of a ZkAsset should accurately report information on the linked token, e.g. name, symbol, decimals.

Current Behaviour

All linked tokens are reported to have a value of "0" for decimals and an empty string for name (symbol isn't included).

I'm trying to display a ZkAsset's balance in terms of its equivalent value in public tokens so I need to know the value of decimals. Currently this requires me to independently spin up a ERC20 contract instance to call these methods which, while definitely doable, isn't ideal.

Possible Solution

On instantiation of a ZkAsset with a linked token, these properties should be automatically queried and stored.

Steps to Reproduce (for bugs)

  1. Instantiate a ZkAsset
  2. Print out token property

Context

Your Environment

  • AZTEC packages and their versions: v1.10.1 of sdk
@ArnSch
Copy link
Contributor

ArnSch commented May 11, 2020

Sorry @TomAFrench just getting to this. Just want to double check, do you mean the linkedToken property on the zkAsset?

If so, that is really an address, which you'll have to call to get information specific to the ERC20 (like the name of the token, if any). For the total amount of public value of a token stored within Aztec, you want the totalSupply property on the NoteRegistry associated with the zkAsset, which can be had by calling getRegistry() on ACE and giving it the address of the deployed zkAsset.

@TomAFrench
Copy link
Member Author

TomAFrench commented May 11, 2020

Hey, no worries.

When I create a zkAsset, I get not only a linkedToken property but a token property as shown below.

Screenshot_2020-05-11_11-54-39

I'm coming at this from the perspective of (starting from only having the address of the zkAsset) printing the private and public balances for a particular user both in terms of the ERC20 value (i.e. accounting for the scaling factor) with the correct number of decimals. I can scale the private balance to be in terms of wei using the sdk but as you mention, getting the proper number of decimals to scale this by would require instantiating a contract object and making another call to get this information before the balances could be displayed.

As this would be a common task for building with zkAssets I thought it would be worth automatically caching this data within the token object. I'd preferably like to avoid having the instantiate another contract object and make an another call to get this information if possible as I would likely have to do it whenever I interacted with a zkAsset.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants