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

Add faucet script #174

Merged
merged 1 commit into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')
Loading