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

Unable to make ERC20 Transfer or any other transfer on self-hosted GETH Blockchain/Node #258

Open
waqaarali opened this issue Jan 10, 2024 · 6 comments
Labels
question Further information is requested

Comments

@waqaarali
Copy link

waqaarali commented Jan 10, 2024

Error:

Eth::Client::ContractExecutionError (insufficient funds for gas * price + value: balance 0, tx cost 921164820000000, overshot 921164820000000)

client = Eth::Client.create(@rpc_url)
puts client.inspect
puts "Chain ID: #{client.chain_id}"

# <Eth::Contract::GBP:0x00007f83a560e890>
# <Eth::Client::Http:0x00007f83d49ef700 @id=0, @max_priority_fee_per_gas=0.101e10, @max_fee_per_gas=0.4269e11, @host="dlt.xxxx.com", @port=443, @ssl=true, @uri=#<URI::HTTPS https://dlt.xxxx.com>>
# Chain ID: 12345

puts "Contract Name: #{client.call(@contract, "name")}"
puts "Contract Symbol: #{client.call(@contract, "symbol")}"
puts "Contract Total Supply: #{client.call(@contract, "totalSupply")}"
puts "Contract Wallet Balance: #{client.call(@contract, "balanceOf", @wallet_address)}"

# Contract Name: Great British Pound Stable coin
# Contract Symbol: GBP
# Contract Total Supply: 100000000000000000000000000
# Contract Wallet Balance: 99898899000000000000000000

tx = client.transfer_erc20_and_wait(@contract, to, 1, sender_key: @private_key, legacy: true, gas_limit: 21578)
puts "Tx: #{tx}"

# Eth::Client::ContractExecutionError (insufficient funds for gas * price + value: balance 0, tx cost 921164820000000, overshot 921164820000000)

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.

@q9f q9f added the question Further information is requested label Jan 10, 2024
@q9f
Copy link
Owner

q9f commented Jan 10, 2024

Hi, you don't have any Ether to pay transaction fees.

You can see it in the error message: "balance 0"

@waqaarali
Copy link
Author

waqaarali commented Jan 10, 2024

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.

@q9f
Copy link
Owner

q9f commented Jan 11, 2024

You only print out the balance of the GBP token (99898899000000000000000000), not the CUSH balance (0?).

Try client.get_balance()

@waqaarali
Copy link
Author

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

@q9f
Copy link
Owner

q9f commented Jan 11, 2024

In that case, the node you are connected to is out of sync. How did you initialize the client?

@waqaarali
Copy link
Author

waqaarali commented Jan 11, 2024

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)

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

No branches or pull requests

2 participants