Skip to content

RPCError: got code -32000 with msg "insufficient funds for transfer" #153

Open
@Sahil-Kundaliya

Description

@Sahil-Kundaliya

i have "total_balance_formatted": "0.000528902815064832",

here is code

double amount = 0.000128902815064832;
BigInt bigIntValue = BigInt.from(amount * pow(10, 18));
EtherAmount ethAmount =
EtherAmount.fromBigInt(EtherUnit.wei, bigIntValue);
var apiUrl =
"https://eth-sepolia.g.alchemy.com/v2/XXXmy_APi_KeyXXX";

      var httpClient = http.Client();
  var ethClient = Web3Client(apiUrl, httpClient);

  EthPrivateKey credentials = EthPrivateKey.fromHex('0x$XXXMy_private_KeyXXX');
  
  EtherAmount etherAmount = await ethClient.getBalance(credentials.address);
  EtherAmount gasPrice = await ethClient.getGasPrice();

  log('SSS amount is -= $etherAmount');
  print('Balance in Wei: ${etherAmount.getInWei}');
  print('Balance in Ether: ${etherAmount.getValueInUnit(EtherUnit.ether)}');
  {

this is out put why is 0.0 ??
flutter: Balance in Wei: 0
flutter: Balance in Ether: 0.0
}
await ethClient.sendTransaction(
credentials,
Transaction(
to: EthereumAddress.fromHex(XXX_receiver_XXX),
gasPrice: gasPrice,
value: txValue,
),
chainId: 11155111,
);

  {

error is => RPCError: got code -32000 with msg "insufficient funds for transfer".
}

but I have amount in wallet but it's showing 0.0 and get this error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions