what if the ethereum accounts balance value low than per eth.sendTransaction gas cost, Can the little ether transfer to another account? - account

What if the ethereum accounts balance value low than per eth.sendTransaction gas cost, Can the little ether transfer to another account?
Can the gas cost default account pointer to another?
eth.sendTransaction({from:eth.accounts[1], to: eth.accounts[2], value:50000000000000}) //the value low the gas cost 21000
I0318 00:24:21.360815 internal/ethapi/api.go:1143] Tx(0x33b58084a35e99245b9c931204a0d161b9d00f9fae5ffb307aff29f200e5cd30) to: 0x49fbd70ca9f90972806c375a111d08950d203f96
"0x33b58084a35e99245b9c931204a0d161b9d00f9fae5ffb307aff29f200e5cd30"
what if eth.getBalance(eth.account[1]) < gas cost 21000, can the execution be successful ?

The simple answer is, if you don't have enough ether to make a successful transaction, the transaction will fail. You always need enough Ether to fund your transactions.
Having less than the required gas cost value will result in your small Ether amount not being able to be moved until the cost to move the Ether is small enough for you to afford.

Related

Everscale blockchain. difference between tvm.rawReserve and tvm.accept

I can't find in any way what is the difference between tvm.rawReserve(address(this).balance, 0) и tvm.accept()?
Before executing a smart contract:
the total amount of ever on the contract address and those who came with message is considered (for external message 0, for internal how many were sent)
storage fee is deducted from this amount
execution of the smart contract begins
For payment for the execution of a smart contract, it is always debited from the account balance.
if it is an external message (and 0 coins were transferred with it)
that is, a small credit for which you can check the require and, if something is wrong, cancel the transaction. in this case, nothing will be removed from the account balance.
If the checks were successful and it is necessary to execute the rest of the function code, payment for the execution of the transaction is made from the balance of the contract:
tvm.accept() — no gas limit
tvm.rawReserve(uint value, uint8 flag) — set the gas limit, that is, we reserve part of the funds and it will not be possible to spend more than this value. See also tvm.setGasLimit(uint g).

Decentraland total supply is difference in Ethereum and polygon?

I learning about blockchain and look in mana token Decentraland. I compared total supply in etherscan and polygonscan but there are difference why?
The Total Supply coinmarketcap: 2,193,554,627 https://coinmarketcap.com/currencies/decentraland/
The Max Total Supply: etherscan: 2,193,554,627 https://etherscan.io/token/0x0f5d2fb29fb7d3cfee444a200298f468908cc942
The Total Supply polygonscan: 3,881,772 https://polygonscan.com/token/0xa1c57f48f0deb89f569dfbe6e2b7f46d33606fd4
any one can answer for it pleas.
I know some tokens use polygon or binance chain beside ethereum to add more scalable and less fee? if that true
but there are difference why?
One of the numbers is wrong.
add more scalable and less fee? if that true
yes

Do you have to spent the entire output of a bitcoin transaction?

After reading about how bitcoin is transferred, I learned that you take the outputs of a previous transaction and use them as inputs for a current transaction, in other words you use the transaction id of the previous transaction to supply coins to the current one. There can be multiple inputs and outputs but if you want to spend the bitcoin in an output do you have to spend the entire output or can you spend part of one output and then use that transaction id later to spend the rest of that output. How would the UTXO database keep track of this and handle the math?
Unspent outputs are claimed by the miner of the block. Transaction fees are just unspent outputs.
If you want to spend the bitcoin in an output do you have to spend the entire output or can you spend part of one output and then use that transaction id later to spend the rest of that output.
Yes, you need to spend all of the outputs unless you plan to donate it to the block miner. Usually this is achieved by paying the "change" back to yourself.

How to feed price from oracle and keep it up to date in another smart-contract?

User interacts with contract, and I need to take a fee from this interaction. Like 1$.
I need stable 1$ equivalent of ETH.
Is there way to update this price ticker (ETH/USD) (well once a day is enough) before (!) user interact with contract? So when he sign it, I can ask for exact 1$ equivalent from his address?
Yes. just get the price in the function at first place.
by Ahmad Gorji

Q-learning value update

I am working on the power management of a device using Q-learning algorithm. The device has two power modes, i.e., idle and sleep. When the device is asleep, the requests for processing are buffered in a queue. The Q-learning algorithm looks for minimizing a cost function which is a weighted sum of the immediate power consumption and the latency caused by an action.
c(s,a)=lambda*p_avg+(1-lambda)*avg_latency
In each state, the learning algorithm takes an action (executing time-out values) and evaluates the effect of the taken action in next state (using above formula). The actions are taken by executing certain time-out values from a pool of pre-defined time-out values. The parameter lambda in above equation is a power-performance parameter (0_<lambda<1). It defines whether the algorithm should look for power saving (lambda-->1) or should look for minimizing latency (lambda-->0). The latency for each request is calculated as queuing-time + execution-time.
The problem is that the learning algorithm always favors small time-out values in sleep state. It is because the average latency for small time-out values is always lower, and hence their cost is also small. When I change the value of lambda from lower to higher, I don't see any effect in the final output policy. The policy always selects small time-out values as best actions in each state. Instead of average power and average latency for each state, I have tried using overall average power consumption and overall average latency for calculating cost for a state-action pair, but it doesn't help. I also tried using total energy consumption and total latency experinced by all the request for calculating cost in each state-action pair, but it doesn't help either. My question is: what could be a better cost function for this scenario? I update the Q-value as follows:
Q(s,a)=Q(s,a)+alpha*[c(s,a)+gamma*min_a Q(s',a')-Q(s,a)]
Where alpha is a learning rate (decreased slowly) and gamma=0.9 is a discount factor.
To answer the questions posed in the comments:
shall I use the entire power consumption and entire latency for all
the requests to calculate the cost in each state (s,a)?
No. In Q-learning, reward is generally considered an instantaneous signal associated with a single state-action pair. Take a look at Sutton and Barto's page on rewards. As shown the instantaneous reward function (r_t+1) is subscripted by time step - indicating that it is indeed instantaneous. Note that R_t, that expected return, considers the history of rewards (from time t back to t_0). Thus, there is no need for you to explicitly keep track of accumulated latency and power consumption (and doing so is likely to be counter-productive.)
or shall I use the immediate power consumption and average latency
caused by an action a in state s?
Yes. To underscore the statement above, see the definition of an MDP on page 4 here. The relevant bit:
The reward function specifies expected instantaneous reward as a
function of the current state and action
As I indicated in a comment above, problems in which reward is being "lost" or "washed out" might be better solved with a Q(lambda) implementation because temporal credit assignment is performed more effectively. Take a look at Sutton and Barto's chapter on TD(lambda) methods here. You can also find some good examples and implementations here.