Created
November 3, 2021 21:18
-
-
Save Kygandomi/a5377de96e99fb50b73da51b4b01a0e4 to your computer and use it in GitHub Desktop.
Chia Password Coin Tutorial 5 Snippet 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/create', methods=('GET', 'POST')) | |
async def create(): | |
await setup_blockchain_connection() | |
# If a post request was made | |
if request.method == 'POST': | |
# Get variables from the form | |
password = (await request.form)['password'] | |
amount = (await request.form)['amount'] | |
# Get information for coin transaction | |
coin_txaddress = create_coin_txaddress( | |
create_coin_password_hash_from_string(password)) | |
# Get the ID of the wallet we will transact with | |
wallets = await wallet_rpc_client.get_wallets() | |
wallet_id = str(wallets[0]["id"]) | |
# Try to send the transaction to the network | |
tx = await wallet_rpc_client.send_transaction(wallet_id, int(amount), coin_txaddress) | |
# Redirect back to the home page on success | |
return redirect(url_for('index')) | |
# Show the create from template | |
# For GET method | |
return await render_template('create.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment