We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

3

The pattern you are using is valid for certain table-like sets, but you should be aware of the limitations. It is ill-advised to do anything with a contract that loops - Getting Loopy with Solidity. You can, however, make it possible for a client to loop. It should be understood that "client" is an off-chain entity, in this context, because if it wasn't ...


3

Trust me. Everytime (everytime!) you are thinking to loop trough a dataset whose dimensions you cannot predict at the “start of the time“ in a blockchain based system, you are using blockchain for the wrong thing and/or your algorithm must be changed by rethinking it. Your model should be something where if a new “user” is added, the simply operation to add ...


2

What is the meaning of stipend if transactions are always have gas limit set by sender? Not really. When EOA calls contract A, the gas limit is set in the transaction, this is true. However, when contract A calls contract B, contract A may set limit on how much gas the contract B is allowed to spend. This limit may be lower than the remaining gas ...


1

The stipend is 2300, not 23000. A scenario where this stipend is not enough: Changing a state-variable from zero to non-zero.


0

This random number generator could easily be manipulated by miners. When constructing next block to be mined, the miner may freely choose set of transactions to be included, and may place the transactions in arbitrary order. Also, the miner may adjust block timestamp and probably some other block attributes. By playing with these possibilities, the miner ...


2

(I'm sure this has come up before. If someone can find a previous answer then please duplicate... ) From the Yellow Paper, Appendix G, you'll see the following line: Gsset - 20000 - Paid for an SSTORE operation when the storage value is set to non-zero from zero. Meaning the first time you write a variable to storage, it's more expensive by 20,000 gas....


1

This is not unique to arrays, but to any state-variable in your contract. Changing from zero to non-zero costs more gas than changing from non-zero to non-zero.


1

The total transaction fee is calculated as (gasPrice * gasUsed). The following example shows how to obtain these values using web3.py: gas_price = web3.eth.getTransaction(transaction_hash).gasPrice gas_used = web3.eth.getTransactionReceipt(transaction_hash).gasUsed transaction_cost = gas_price * gas_used The value of transaction_cost is denominated in wei....


1

The whole function will revert and the ether will be returned to the sender minus the cost of the transaction.


1

Loops themselves are not as expensive as sending some tokens to number of addresses. Usually, in order to send some tokens to an address, you need to update at least two storage slots: sender's balance and recipient's balance. While updating sender's balance may be optimized in case the same sender does several transfers in one transaction, recipient ...


1

Miners generally mine transactions that will pay them the highest gas fee for doing so. Because of this, each block is a sort of auction where the highest bidders (in terms of gasPrice) get included in the block. A transaction sitting in the txPool generally means that the supplied gasPrice is not high enough for a miner to want to accept it. You can check ...


1

Sure, this is possible and is already implemented in many token smart contracts, for example in Stasis EURS Token. There are also ERCs for this: ERC-865, ERC-1228. The idea is than token holder digitally signs transfer order, but, instead of sending it to the smart contract directly, gives it to a third party called “relayer”. The relayer forwards the ...


0

These answers are good but I noticed they are a little on the old side and there is a way to send a transaction even when they have no ether. They just need a little help: https://medium.com/@andreafspeziale/understanding-ethereum-meta-transaction-d0d632da4eb2 It's tricky, but it doesn't depend on a protocol upgrade. A grossly summarized process works ...


Top 50 recent answers are included