question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🧐 Motivation The current design pattern for all ERC tokens is to use the uint256 as this interfaces with EVM. This is understandable. However, not all use cases of these tokens need a pure uint256 standard. The most important part is that we keep the interface of the uint256 but in the library.cairo we can make a low-level conversion into a felt if it is appropriate for the use case. It is then the responsibility of the developer to choose what they wish to use.

For the upcoming ERC1155 standard this is particularly helpful as it will effectively half the storage space for the tokens.

📝 Details Proposes design pattern:

library_packed.cairo

This file would simply have a low-level conversion from uint to felt and vice versa where needed. This would then just be chosen by the developer when they deploy the contract.

Thoughts?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:6
  • Comments:16 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
milancermakcommented, Jun 1, 2022

Using felts instead of Uint256 would also save on transaction execution resources.

I was curious about the savings. I forked the repo and created a library_felt for ERC20 (code can be found in this branch). The public API is kept the same, but internally, it uses felts for everything.

In a simple transfer TX went from needing 870 steps and 32 range_check_builtins to 683 steps and 18 range_check_builtins; the rest stayed the same. That’s a saving of about 15 gas / transfer (870 - 683) * 0.05 + (32 - 18) * 0.4.

Not much in absolute terms, but somewhat significant in relative terms. Given that these contracts are going to be the canonical implementation of tokens used on Starknet, that we’re still early and that scaled out to hundreds of millions of TX in the future, the savings are serious. I’d urge OZ to consider a felt-based implementation for ERC tokens as originally suggested.

2reactions
ponderingdemocrituscommented, May 24, 2022

yes, very valid point. I think you might be correct, the only question is if storage structs costs more to update, or if they count towards two storage updates on every write

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Packed Project Libraries in LabVIEW Projects - NI
LabVIEW packed project libraries are project libraries that package multiple files into a single file with a .lvlibp file extension.
Read more >
Using Packed Project Libraries in LabVIEW Projects
A packed library contains only LabVIEW files. By default, LabVIEW saves non-LabVIEW files to the same destination directory as the packed library.
Read more >
Packed Project Library - LabVIEW Wiki
A Packed Project Library, or (PPL), is a compiled version of the LabVIEW Project Library. The LabVIEW Project Library has the file extension ......
Read more >
PACKED Subscription Service - Auglaize County Public Library
PACKED Subscription Service. PACKED Kids Subscription Service Sign Up for PACKED Kids. PACKED Teens Subscription Service Sign Up for PACKED TEENs.
Read more >
Packing Your Library
Library Packing Materials ... You want to have plenty of strong book boxes (all the same size), a packing tape gun, and packing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found