Skip to content

Commit

Permalink
Add faucet script
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zk committed Aug 2, 2023
1 parent 699e90b commit c3281fd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docker/Dockerfile.evmos-node.developer
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
FROM ghcr.io/zama-ai/fhevm-decryptions-db:v0.1.5 as oracle-env
FROM ghcr.io/zama-ai/fhevm-tfhe-cli:v0.1.2 as tfhe-cli

FROM ghcr.io/zama-ai/evmos-node:v0.1.7-beta
FROM ghcr.io/zama-ai/evmos-node:v0.1.7

WORKDIR /config

Expand All @@ -12,7 +12,7 @@ ADD ./public.ed25519 .
ADD ./scripts/prepare_volumes_from_fhe_tool.sh .
ADD ./scripts/prepare_validator_ci.sh .
ADD ./scripts/run_developer_image.sh .

ADD --chmod=755 ./faucet.py /usr/local/bin/faucet

COPY --from=oracle-env /usr/local/app/fhevm-decryptions-db .
COPY --from=oracle-env /usr/local/app/Rocket.toml .
Expand Down
34 changes: 34 additions & 0 deletions faucet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/env python3

import sys
import os
import subprocess
import json

if len(sys.argv) < 2:
print('Pass address for tokens in the first argument')

FAUCET_DEST_ADDRESS = sys.argv[1]
FAUCET_WALLET_NAME = os.getenv('FAUCET_WALLET_NAME', default='mykey1')
FAUCET_AMOUNT = os.getenv('FAUCET_AMOUNT', default='100000000000000000000')
DENOM = os.getenv('DENOM', default='aevmos')

def get_faucet_address():
addresses = json.loads(subprocess.check_output(['evmosd', '--output=json', 'keys', 'list']))
for address in addresses:
if address['name'] == FAUCET_WALLET_NAME:
return address['address']
return None

def get_bech32_addr(ethereum_address):
output = subprocess.check_output(['evmosd', 'debug', 'addr', ethereum_address]).decode('utf-8')
bech32 = next((x for x in output.splitlines() if x.startswith('Bech32 Acc:')))
return bech32.split(': ')[1]

faucet_address = get_faucet_address()
if faucet_address is None:
print('Faucet account not found with name ' + FAUCET_WALLET_NAME)
os.exit(1)

dst_bech_addr = get_bech32_addr(FAUCET_DEST_ADDRESS)
os.system(f'evmosd --output=json tx bank send {faucet_address} {dst_bech_addr} {FAUCET_AMOUNT}{DENOM} --from {FAUCET_WALLET_NAME} --gas-prices 1{DENOM} -y')

0 comments on commit c3281fd

Please sign in to comment.