Obtain contract account address via Pyteal

Documentation states “Contract accounts act in a similar fashion to escrow accounts, where when the smart contract is compiled it produces an Algorand address”. How do I obtain a contract’s address in pyteal/algosdk?
I deploy my application like that:

approval_teal = compileTeal(approval_program(), Mode.Application)
approval_compiled = compile_program(algod_client, approval_teal)

clear_teal = compileTeal(clear_state_program(), Mode.Application)
clear_compiled = compile_program(algod_client, clear_teal)

app = transaction.ApplicationCreateTxn(
    deployer_pub,
    suggestion,
    transaction.OnComplete.NoOpOC.real,
    approval_compiled,
    clear_compiled,
    global_schema,
    local_schema,
    []
)

signed_app = app.sign(deployer_priv)
tx_id = signed_app.transaction.get_txid()

algod_client.send_transactions([signed_app])

However, this transaction shows up as “App Call” with a target of “n/a” in Algo Explorer. Do I need to compile this differently?

What you created is a stateful smart contract / application.
Such a smart contract does not have an address.

Contract accounts should be stateless smart contracts.

See Algorand Developer Docs for details.

If you need your application/stateful smart contract to have an escrow account, you can do as in this tutorial: Algorand Developer Portal

1 Like

Thank you, Fabrice. Can you advise how stateless/stateful relates to the concepts of Signature Mode and Application Mode described in documentation? Is a stateless smart contract be compiled via Signature mode?

stateless = signature mode
stateful = application mode

fabrice, how did you know that the contract from Supirogurafu’s post is a stateful smart contract and not a stateless smart contract?

Only stateful smart contract have approval/clear programs.
But this was more of a guess.

1 Like