Ejemplo n.º 1
0
def opt_in_app(client, private_key, index):
    # declare sender
    sender = account.address_from_private_key(private_key)
    print("OptIn from account: ", sender)

    # get node suggested parameters
    params = client.suggested_params()
    # comment out the next two (2) lines to use suggested fees
    params.flat_fee = True
    params.fee = 1000

    # create unsigned transaction
    txn = transaction.ApplicationOptInTxn(sender, params, index)

    # sign transaction
    signed_txn = txn.sign(private_key)
    tx_id = signed_txn.transaction.get_txid()

    # send transaction
    client.send_transactions([signed_txn])

    # await confirmation
    wait_for_confirmation(client, tx_id)

    # display results
    transaction_response = client.pending_transaction_info(tx_id)
    print("OptIn to app-id:", transaction_response['txn']['txn']['apid'])
Ejemplo n.º 2
0
def opt_escrow_into_manager(escrow_logicsig, manager_app_id,
                            liquidity_token_asset_id, token1_asset_id,
                            token2_asset_id):
    print("Opting Escrow into Manager contract...")

    program = base64.b64decode(escrow_logicsig)

    lsig = transaction.LogicSig(program)

    args = [
        liquidity_token_asset_id.to_bytes(8, 'big'),
        token1_asset_id.to_bytes(8, 'big'),
        token2_asset_id.to_bytes(8, 'big')
    ]

    txn = transaction.ApplicationOptInTxn(sender=lsig.address(),
                                          sp=algod_client.suggested_params(),
                                          index=manager_app_id,
                                          app_args=args)

    lsig_txn = transaction.LogicSigTransaction(txn, lsig)

    tx_id = algod_client.send_transaction(lsig_txn)

    wait_for_transaction(tx_id)

    print(
        f"Opted Escrow into Manager contract successfully! Tx ID: https://testnet.algoexplorer.io/tx/{tx_id}"
    )

    print()
Ejemplo n.º 3
0
def opt_in_to_app(
    client,
    user,
    user_priv_key,
    suggested_params,
    app_id,
):
    txn = transaction.ApplicationOptInTxn(
        user,
        suggested_params,
        app_id,
    )
    signed_txn = txn.sign(user_priv_key)
    tx_id = client.send_transactions([signed_txn])
    return tx_id
Ejemplo n.º 4
0
def opt_user_into_contract(app_id):
    print(f"Opting user into contract with App ID: {app_id}...")

    txn = transaction.ApplicationOptInTxn(
        sender=TEST_ACCOUNT_ADDRESS,
        sp=algod_client.suggested_params(),
        index=app_id).sign(TEST_ACCOUNT_PRIVATE_KEY)

    tx_id = algod_client.send_transaction(txn)

    wait_for_transaction(tx_id)

    print(
        f"Opted user into contract with App ID: {app_id} successfully! Tx ID: https://testnet.algoexplorer.io/tx/{tx_id}"
    )

    print()