Hot 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

(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....


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

Yes! This pattern of transactions is called metatransactions. As you described, your user would sign the transaction, but you would send the transaction to the network via a metatransaction. There are a number of different ways to implement it. The Gas Station Network (GSN) by OpenZeppelin provides this as a service and is worth considering for your use.


1

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


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 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 ...


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....


Only top voted, non community-wiki answers of a minimum length are eligible