New answers tagged

0

Can this address spend all my ETH without me approving it via my MetaMask? The approve() function is part of the ERC-20 standard. Approving someone else's address gives them permission to transfer your ERC-20 tokens. It does not grant permission over your ETH. Only the holder of the private key - which is hopefully only you - can move or spend your ETH. So: ...


2

Yes, modulo is cheaper in unchecked arithmetic! Take the following code: pragma solidity ^0.8.0; contract Modulos { function foo(uint256 x, uint256 y) external view returns (uint256 result, uint256 gasUsed) { uint256 startGas = gasleft(); result = x % y; gasUsed = startGas - gasleft(); } function bar(uint256 x, ...


1

Usually it is safe to leave the gas estimation for the wallet itself and not to try to do it yourself. In the case wallets cannot estimate the gas, which sometimes happens for complex transactions, you can do test transactions on testnet and figure out how many gas units the transactions spend and then use that as a hardcoded limit.


0

You should be able to recover access to your Coinbase wallet through your Coinbase account. Try contacting them via email!


1

View and Pure functions are gasless only if they do not get called from the contract internally. The function in the question would be gasless if called externally. Pure functions do not read or modify state, where as View functions read but do not modify state.


0

If the transaction's recipient is a contract the Ethereum's rules state its bytecode will be executed, so at least one opcode will be executed. A contract compiled with solidity will make several checks to determine if it is a function call and dispatch it properly. In order to accept ether payments a contract has to implement the receive function (or the ...


1

Possibly someone with deeper knowledge of compilation details will chime in with more precision. Intuitively, one might expect a slight difference to account for the extra steps of jumping into another section of code, packing return arguments, and unpacking received arguments, and them carrying to assign the value to foo_value. The difference could be ...


3

Yup, it does cache the numbers, even without the optimizer enabled! When passing 65535 (max uint16) as the parameter x, it costs 1003 gas to run either foo or bar. I ran this test with Solidity v0.8.3 on Remix. contract PowersOfTwo { uint256 internal constant TWO_POW_1 = 2**1; uint256 internal constant TWO_POW_2 = 2**2; uint256 internal constant ...


1

Gas powers the transaction. The transaction consumes a certain amount of gas. Any remaining supplied (sent) gas is returned to the sender so there is no risk in sending extra gas. The transaction fails if the work cannot be completed before all the gas is gone. GasPrice is Ether to spend per unit of gas burned. Think of it like paying $4.50/gal for gas and ...


4

When you create a transaction you set two parameters: gas: Maximum amount of gas to be used gasPrice: Price to pay for each gas unit To execute the transaction your account needs to have at least gas * gasPrice ether. Before executing your account is charged with gas * gasPrice. After the transaction has completed its execution unused gas and refunded gas ...


0

I deployed the contract in remix with different solc versions. Solc Private Public 0.8.2 439,788 609,500 0.7.6 312,372 440,476 0.6.12 308,678 436,781 There's a notable increment 160k in 0.8, but in previous version was similar 140k. Since requests returns a structure making it public requires the serialization of the structure that doesn't exists when ...


1

The address 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 belong to a contract. Contracts don't pay fees, users invoking them pay the transactions fees. In this particular case the contract is WETH. It is used to wrap ETH as an ERC20 token. It is used by several exchanges.


0

I just need a simple way to pay fees for other user. I think you might be disappointed. The technique involves setting up considerable preconditions including changes to the contract the users will use. Such changes are not applicable to published contracts in a general way because most contracts are immutable. For the developer that wants to "install&...


2

You can include in your contract a key that only your app know, but... the Ethereum net make public the smart contracts code, then I dont know how you can avoid decrypting the communication between the app and the contract. Maybe if you dont verify the contract the code of it stay hidden. Other solution I can think is to create 2 contracts, where the second ...


0

Contracts evaluate signed transactions from users. They don't evaluate how the user composed the transaction or signed it. From a human perspective, it is helpful if a UI guides the user, composes the transaction and offers it for signing but, typically, this is of no concern to the contract. Contracts need to guard their internal integrity regardless of ...


0

This is more of an aside, because it's not clear what you're asking. (I see lots of transactions involving that contract, all of them with a fee in the last column [once they move from 'pending' state].) This might be a stupid question but as far as I knew as soon as you send a transaction on ethereum you pay a transaction fee Not necessarily. You can ...


0

I'm new to metamask and receive(d) failed transactions as well, and also default not 21000 gas limit but like 200-300k which makes the fee around 50-80$. What I found, and like to share, is: Go to settings, general, advance, and there you can click on 'reset' and all previous transactions and history is gone (NOT your money). This seems to be helping for ...


3

You can actually do a double flashloan, but the success will depend on the total amount of gas consumed in the transaction. In fact, you don't need to have two contracts and you can request the two loans from the same contract. Below is a simple example on how this could be done: // SPDX-License-Identifier: MIT pragma solidity ^0.7.3; import {IERC20} from &...


Top 50 recent answers are included