Questions tagged [algorithm]
The algorithm tag has no usage guidance.
17
questions
0
votes
1
answer
21
views
Solidity deterministic shuffle algorithm
I'm finding a deterministic shuffle algorithm
function shuffle(unit256 seed, uint256 length, uint256 index) external returns (uint256);
Given the same seed and length. different index input will ...
1
vote
0
answers
49
views
Rebase algorithm
I'm building a rebase token and need some help with the algorithm. These are the variables, constants, and constraints (the values themselves are just examples):
Set of variables 1:
a1 = ...
0
votes
0
answers
50
views
Merkle Patricia Trie insertion, deletion and verification algorithms
I've googled this for a while, but online guides mostly explain the addition part and do not give a comprehensive example.
What is the algorithm for such operations in Merkle Patricia Trie (insertion, ...
1
vote
2
answers
2k
views
I was trying to convert private key of an account to its public key but getting an error
code:
const accountFrom = web3.eth.accounts.privateKeyToAccount(privateKey);
getting error:
throw new web3_errors_1.InvalidPrivateKeyError();
^
InvalidPrivateKeyError: Invalid Private Key, Not a ...
2
votes
1
answer
139
views
Can't understand this GCD algorithm
I was trying to get the GCD of two numbers. This function I saw on github works fine but I have a confusion here.
The function :
function _gcd(uint256 a, uint256 b) external pure returns (uint256) {...
0
votes
2
answers
34
views
NFT Price should be set by the algorithm and not by the owner
Just like how the algorithm controls the videos on youtube and not the platform itself.
How can the price of NFT be set by the algorithm (from set of data that keeps changing).
The owner of NFT ...
1
vote
1
answer
87
views
Getting two different booleans calling a function 2 times in a row
I tried to create a function which could return me 2 different booleans after I call it two times in a row. I tried my best to use different random methods like storing block.timestamp in an uint, or ...
0
votes
1
answer
28
views
Are there any downsides to revealing all the participants of a lottery, to the public?
In my smart contract which is lottery I generate a random number. Then I pick a user based on his sequential place in the list of all the participants. This sequential place gets assigned to every ...
0
votes
1
answer
89
views
How to write a linear formula for percentage in Solidity?
So id like to write this function in solidity but im having issues because of the integers not being accepted.
s being the startin time. Lets say 1 second in unix time.
x being the ending time. Lets ...
0
votes
0
answers
101
views
Random DNA mix in Solidity
Hello I have DNA mix function and I am trying to implement random function while mixing DNA
for example dad DNA is 10 10 10 10 10 10 10 10 10 10 and mum DNA is 21 21 21 21 21 21 21 21 21 21 and child ...
1
vote
0
answers
30
views
Unexplained listing alert
Sorry for the newbie question
But there are actually telegram channel which deliver listing alert seconds to minutes before the actual listing on CoinMarketCap and CoinGecko
They claim they dont work ...
1
vote
1
answer
29
views
smart way to keep track of staking info
I have a contract for staking NFTs, called "Stake".
where someone will send a token and claim some rewards over time. I need to keep track of what/who sends.
something like this
struct ...
1
vote
1
answer
40
views
Distribution coefficient
I'm building a dapp and I need some help with creating the formula for a "distribution coefficient/index" (my math is rusted). The idea behind it is:
There's a total balance. Let's call it &...
1
vote
1
answer
27
views
What are the most prominent dispute resolution frameworks deployed on Ethereum
Dispute Resolution may become a very important paradigm for multidimensional consensus systems such as Ethereum in the near future. In this perspective, I am going through the existing dispute ...
0
votes
0
answers
2k
views
x*y = k Constant Product Market Maker
A short recap for Context
In its basic form, a liquidity pool holds 2 tokens and creates a new market for that particular pair of tokens.
When a new pool is created, the FIRST liquidity provider is ...
1
vote
0
answers
35
views
What is the fastest way to implement the find first set algorithm in Solidity?
As per Wikipedia, a find first algorithm is:
a bit operation that, given an unsigned machine word, designates the index or position of the least significant bit set to one in the word counting from ...
0
votes
0
answers
129
views
Pull-based reward distribution (Rewards Compounding) among stakeholders according to their shares in staking
In a naive implementation, the staking contract would
push fractional payments to all the participants each time a
reward gets distributed. However, in such an implementation
the distribute function ...