Support unit parsing in all relevant configs (e.g "10 ether", "200 wei", etc..)
See original GitHub issueOutline
A lot of configurations in embark need to define an amount in wei. The goal of this task is to support specifying these values as a nice string of the type “<number> <unit>” for e.g “200 finney”. The code for this is already available in embark in the utils class here. The goal is to support this feature in all the required configs.
Acceptance Criteria
- support “<number> <unit>” config
**
unit
can be:wei
,kwei
,Kwei
,babbage
,femtoether
,mwei
,Mwei
,lovelace
,picoether
,gwei
,Gwei
,shannon
,nanoether
,nano
,szabo
,microether
,micro
,finney
,milliether
,milli
,ether
,kether
,grand
,mether
,gether
,tether
** in the following fields: ***config/blockchain.js
:gasPrice
***config/contracts.js
:gasPrice
*** any other relevant fields - if the config value is a) not a string nor b) the unit is not specified nor c) is a string starting with ‘0x’ then the value should be assumed to be in
wei
Issue Analytics
- State:
- Created 5 years ago
- Comments:23 (7 by maintainers)
Top Results From Across the Web
Support unit parsing in all relevant configs (e.g "10 ether ...
The goal of this task is to support specifying these values as a nice string of the type "<number> <unit>" for e.g "200...
Read more >Documentation - Ethers.js
The JSON-RPC API is another popular method for interacting with Ethereum and is available in all major Ethereum node implementations (e.g. Geth and...
Read more >Display Logic and Input - ethers
The parseUnits will parse a string representing ether, such as 1.1 into a BigNumber in wei, and is useful when a user types...
Read more >Cisco Firepower 4100/9300 FXOS Command Reference
To view information about operations and current configuration in various command modes, use the show command. Many of the FXOS CLI command modes...
Read more >Remix Documentation - Read the Docs
Remix IDE is used for the entire journey of smart contract development by users at every knowledge level. It requires.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kpulkit29 It is indeed a bit hard to follow if you aren’t familiar with the codebase (neither am I). However, I did some digging and I think what needs to be done is this:
@iurimatias mentioned that a lot of gas related configurations in embark need to be defined in Wei. AFAICT, he’s referring to configuration options like
gas
,gasLimit
andtargetGasLimit
. Notice that those options are used incontracts.json
,genesis.json
andblockchain.json
respectively. Every embark project has these files.Now, you can see that all of these options define their value in different formats, sometimes it’s a string (
"auto"
), sometimes it’s a hex string ("0x..."
) and sometimes it can be a number (800000
). All of these values are just different representations. A value can be represented as hex code, binary or decimal number.Specifying values in Wei can be quite cumbersome, considering how huge the numbers can get (1 Ether = 1,000,000,000,000,000,000 Wei (10^18)), that’s why programs often us hex codes to make values easier to read, parse and digest. For humans, it’d be even better if one could say
"1 ether"
instead of1000000000000000000
, or use any other unit that makes sense (Gwei, shannon, finney etc.)It turns out that embark already comes with utility functions to take such a human readable string representation and turn that into the Wei format that embark needs to do its work. One of those functions is
getWeiBalanceFromString()
So what needs to be done is find the places where those configuration files are being loaded (e.g. here and here) and pipe their
gas
,gasLimit
andtargetGasLimit
values through the utility function before they get merge into the overall configuration object, which essentially results in users being able to specify their values in human readable formats 😃To be fair, I couldn’t find a configuration option for
gasPrice
in the codebase that is configurable for users/consumers, but I’m sure @iurimatias can shed some light into darkness here.I hope this makes sense and @iurimatias and @jrainville please correct me here if anything of this is wrong!
Does this help @kpulkit29 ?
This has landed as https://github.com/embark-framework/embark/commit/594d1323faa272ef305e9870b8dd6f8db63f4d10