28 ms·
In my experience with writing quadratic voting contracts in Solidity, the exponent of 2 is mandatory because there's no way to calculate an nth root in Solidity
by numtel 4y ago
In my experience with writing quadratic voting contracts in Solidity, the exponent of 2 is mandatory because there's no way to calculate an nth root in Solidity.
Writing that out though, I realize that the root could be calculated by the client and simply verified on chain.
One token, one vote is an exponent of 1, it should be up to the voters to decide the exponent used based on the issue in order to choose the degree money influences decision making.
- freemint 4y agoFalse. You can very much implement the n-th root. Details depend on the number format chosen (fixed vs floating point emulation). The most obvious method is binary search. You calculate the n-th power for some number and see if it is larger or smaller then then the number you want the root from and narrow it down. Equivalents of the doom trick using integer division and instead of >>1 (which is ÷2) of the exponents + a few newton iterations would also do the trick in floating point format
- numtel 4y agoApparently it is possible. [1] I guess I missed that when I was trying before. [1] https://ethereum.stackexchange.com/questions/38468/calculate-the-nth-root-of-an-arbitrary-uint-using-solidity https://ethereum.stackexchange.com/questions/38468/calculate...