Closed waqaarali closed 1 month ago
Hi, you don't have any Ether to pay transaction fees.
You can see it in the error message: "balance 0"
It should use the native token of the blockchain which is "CUSH". As you can see when I print the wallet balance, it's a number greater than 1. I've rebuilt the same code in JS and have no issues at the moment. I only seem to be getting the issue over here.
Could it be because it isn't detecting the blockchain's currency or something? Is there an extra config for this somewhere?
This blockchain is a private one I have setup using GETH.
You only print out the balance of the GBP token (99898899000000000000000000), not the CUSH balance (0?).
Try client.get_balance()
So how would I get this to work? My CUSH balance is 900k+ and my GBP balance (ERC-20) is 900k+. But when I try to send either CUSH (native token) or the ERC 20, it says insufficient funds as above
In that case, the node you are connected to is out of sync. How did you initialize the client
?
It can't be out of sync, I am replicating the same functionality into Node.js and it works without any issue sadly. Either I'm missing something or something is broken.
This is how I initialize the client:
# Contract
@contract = Eth::Contract.from_abi(name: "GBP", address: @contract_address, abi: @erc20_abi)
# Client
client = Eth::Client.create(@rpc_url) # URL of RPC
balance = client.get_balance(@wallet_address)
transfer = client.transfer_and_wait(to, 1, sender_key: @private_key, legacy: true)
# Regular Transaction
transaction = client.transfer_and_wait(to, 1, sender_key: @private_key, legacy: true)
# ERC 20
transaction_erc20 = client.transfer_erc20_and_wait(@contract, to, 0, sender_key: @private_key, legacy: true, gas_limit: 21578)
# Tried this too but same error
manual_erc20 = client.transact_and_wait(@contract, "transfer", address: to, amount: 0, sender_key: @private_key, legacy: true, gas_limit: 21578)
# These transactions are not all run at once, I have placed them here so you can see what I am trying to do
This blockchain is GETH clone with only 3 nodes (boot node, rpc endpoint & 1 miner)
There is nothing I can do here, the error you are seeing is from your client (not from my library):
insufficient funds for gas * price + value: balance 0, tx cost 921164820000000, overshot 921164820000000
Error:
Any ideas what I may be doing wrong? I tried a normal transfer too but I keep getting the same error. My default coin for this GETH Blockchain is called "CUSH". Please advise further, thanks! I did manage to make sending transactions work via calling the RPC directly, but sadly couldn't get it to work for ERC20, so I thought this would be a better approach. Please advise further.