Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always insufficient funds for gas * price + value #17

Closed
fangao888 opened this issue Jul 6, 2022 · 6 comments
Closed

Always insufficient funds for gas * price + value #17

fangao888 opened this issue Jul 6, 2022 · 6 comments

Comments

@fangao888
Copy link

fangao888 commented Jul 6, 2022

$owner_private = '0x922b775cef0410717c28e0b04c23ffa5a0e2*********';
$owner_address = '0x9118cc4212dCC83dca639de28FC0D47AfdE4C45F';

$token = new Token("0xdac17f958d2ee523a2206206994597c13d831ec7","https://mainnet.infura.io/v3/d5cd9b58d5ca43409486******");
//by this method we allow $myapp_address to send upto 99999 token behalf of $owner_address
$approve_tx = $token->approve($owner_address, "0x4E0E4CbdfBaB08e65F5ECAb25bEAA*******", 9999);
$approve_tx_id = $approve_tx->sign($owner_private)->send();

Hello author, I have a problem!
It keeps prompting insufficient funds for gas
But there is enough ETH in the account
can you help me

@lessmore92
Copy link
Owner

Hi,
You can set custom parameters for gasPrice and gasLimit as 4th and 5th parameters.

Have a look at the approve method definition:

approve(string $ownerAddress, string $spenderAddress, string $amount, string $gasLimit = 'default', string $gasPrice = 'default')

@lessmore92
Copy link
Owner

Did your problem solve?

@suixin406
Copy link

$token = new USDT("https://mainnet.infura.io/v3/8038c7c7********");

$owner_address = '0x1d64720e43342bdd0E824e1dadEF';
$myapp_private = '0xbf15a4a052a3b59c1a5598
8e8a1e35056fbfacf94ce';
$myapp_address = '0x907Dc5716029B907BfFB223f0A*******';
$to_address = '0x907Dc5716029B907BfFB2*******';

$transfer_tx = $token->transferFrom($myapp_address, $owner_address, $to_address, 1);
$transfer_tx_id = $transfer_tx->sign($myapp_private)->send();

How to solve this please?

Uncaught RuntimeException: insufficient funds for gas * price + value

@lessmore92
Copy link
Owner

insufficient funds for gas * price + value

This error usually happens, when the gas price and gas limit parameters value are wrong; in this library, there is a default value for those, But based on time and network (ETH network) gas price needs to be adjusted. Also gas limit is different for various methods.

You can search and learn more about gas price and gas limit, then in all methods of this library, you can set the correct value for these.

@jucci1887
Copy link

jucci1887 commented Dec 1, 2022

hi ,
// transferFrom

   public function transferFrom(string $spender, string $from, string $to, string $amount, string $gasLimit = 'default', string $gasPrice = 'default',string $nonce = '')
  {

    $amount = Number::scaleUp($amount, $this->decimals());
    $data   = $this->buildTransferFromData($from, $to, $amount);
    if(empty($nonce)){
        $nonce  = Number::toHex($this->getEth()
            ->getTransactionCount($spender, 'pending'));
    }

    if (strtolower($gasLimit) === 'default')
    {
        $gasLimit = $this->getGasLimit('transferFrom');
    }
    if (strtolower($gasPrice) === 'default')
    {
        $gasPrice = $this->getSafeGasPrice();
    }

    return (new TransactionBuilder())
        ->setEth($this->getEth())
        ->to($this->contractAddress)
        ->nonce($nonce)
        ->gasPrice("200000000000")
        ->gasLimit("100000")
        ->data($data)
        ->amount(0)
        ->build()
        ;


}

i have setting gasPrice、gasLimit like that, but it cant work . The responce is :
{
"jsonrpc": "2.0",
"id": 724889050,
"error": {
"code": -32000,
"message": "insufficient funds for gas * price + value"
}
}

please , how to fix it ? thanks

@lessmore92
Copy link
Owner

@jucci1887 Does the spender wallet have enough balance to pay the transaction fee?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants