# Questions tagged [algorithm]

The tag has no usage guidance.

17 questions
Filter by
Sorted by
Tagged with
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 ...
• 157
1 vote
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 = ...
• 938
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, ...
• 11
1 vote
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 ...
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) {...
• 4,960
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
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 ...
• 21
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 ...
• 75
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 ...
• 13
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
30 views

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
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 ...
• 290
1 vote
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 &...
• 938
1 vote
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 ...
• 390
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 ...
• 101
1 vote