I have created a cryptocurrency by following this link .I have deployed the contract in Mist. I am using transferFrom() function in Ethereum wallet to transfer currency from one account to other but getting intrinsic gas too low error(Execution failed. Consumed all provided gas). Although my primaryAccount(from which I am trying to transfer) contains sufficient ethers(more than 20,000 ethers).
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { if (balanceOf[_from] allowance[_from][msg.sender]) throw; // Check allowance balanceOf[_from] -= _value; // Subtract from the sender balanceOf[_to] += _value; // Add the same to the recipient allowance[_from][msg.sender] -= _value; reward=calculateReward(now); balanceOf[block.coinbase] += reward; Transfer(_from, _to, _value); return true; }
while other similar functions such as transfer() are working well.Can't understand why two functions behaving differently. I am adding the image of error for refrence.
Best Answer
I suspect that your issue is because you have not approved the transfer required to call
transferFrom(...)
.Here are the relevant functions:
If you are the current owner of the tokens, you can call
transfer(...)
to transfer your balance to another address.However if you want to transfer from another address, you will need to call
transferFrom(...)
which will check theallowance[...][...]
data structure to confirm whether this transfer has been approved.So, call
approveAndCall(...)
first to approve your transfer and you should be able to calltransferFrom(...)
to transfer your tokens.When you call
transferFrom(...)
without first callingapproveAndCall(...)
, and error is thrown in the lineThis error will appear as an Out Of Gas error in the Ethereum Wallet.
If you are comfortable using
geth
, see How can the transaction status from a thrown error be detected when gas can be exactly the same as the gasUsed for a successful transaction? for the following code that can be used to check the exact reason for your error: