Skip to content

Commit

Permalink
add a balance check
Browse files Browse the repository at this point in the history
  • Loading branch information
wuminzhe committed Jun 15, 2023
1 parent 257a3b9 commit b30cd23
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/faucet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require "dotenv/load"

def get_balance(eth_client, address)
eth_client.eth_get_balance(address)["result"].to_i(16)
eth_client.eth_get_balance(address)["result"].to_i(16) / 10**18
end

def get_nonce(eth_client, address)
Expand Down Expand Up @@ -84,15 +84,19 @@ def run_drop(address, network, username)
Eth::Client::Http.new(ENV["PANGORO_ENDPOINT"])
end

# check balance
raise "your address has enough test tokens." if get_balance(evm_client, address) > 200

drop(evm_client, mongo_client, address, network, username)
else
raise "already received it today, please come back tomorrow."
end
end

client = Eth::Client::Http.new("https://pangolin-rpc.darwinia.network")
# client = Eth::Client::Http.new("https://pangolin-rpc.darwinia.network")
# puts get_nonce(client, "0xDa97bC5EE02F33B92A0665620fFE956E21BAEf0f")
puts get_balance(client, "0xDa97bC5EE02F33B92A0665620fFE956E21BAEf0f")
# raise "your address has aleady own enough test tokens." if get_balance(client, "0xDa97bC5EE02F33B92A0665620fFE956E21BAEf0f") > 200
# puts get_balance(client, "0xDa97bC5EE02F33B92A0665620fFE956E21BAEf0f")
# tx = build_drop_tx(client, "0xDa97bC5EE02F33B92A0665620fFE956E21BAEf0f", "pangolin")
# # puts tx.hash
# # puts client.eth_send_raw_transaction(tx.hex)["result"]
Expand Down

0 comments on commit b30cd23

Please sign in to comment.