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

Update faucet.py #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 10 additions & 9 deletions scripts/faucet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from requests import get, post
from hashlib import sha256
import argparse
import json

DEFAULT_URL = "http://0.0.0.0:5000/api/v1/faucet"

Expand Down Expand Up @@ -31,25 +32,25 @@ def compute_pow_solution(challenge, difficulty):
i += 1

if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Request from an amount of token from faucet.')
parser.add_argument('url', action='store', type=str, required=False, default=DEFAULT_URL, help='The faucet url.')
parser.add_argument('token', action='store', type=int, required=False, help='The token address.')
parser.add_argument('amount', action='store', type=int, required=False, default=1000, help='The token amount.')
parser.add_argument('target', action='store', type=str, required=True, help='The target address.')
parser = argparse.ArgumentParser(description='Request an amount of token from faucet.')
parser.add_argument('url', action='store', type=str, default=DEFAULT_URL, help='The faucet url.')
parser.add_argument('token', action='store', type=str, help='The token address.')
parser.add_argument('amount', action='store', type=int, default=1000, help='The token amount.')
parser.add_argument('target', action='store', type=str, help='The target address.')

args = parser.parse_args()

response = request_challenge(args.url)
solution = compute_pow_solution(args.url, response['challenge'], 2)
response = request_transfer({
solution = compute_pow_solution(response['challenge'], 2)
response = request_transfer(args.url, {
'solution': solution,
'tag': response['tag'],
'challenge': response['challenge'],
'transfer': {
'target': args.target,
'token': args.token,
'amount': args.amounr * 10**6
'amount': args.amount * 10**6
}
})

print(response.json())
print(json.dumps(response.json(), indent=2))