Pyteal contract - Algorand

Pyteal contract

post by nikitagugale on Nov 17, 2021

@Subroutine(TealType.none)
    def closeAccountTo() -> Expr:
        return If(App.globalGet(PurchaserApprove) == Int(1)).Then(
            Seq(
                InnerTxnBuilder.Begin(),
                InnerTxnBuilder.SetFields(
                    {
                        TxnField.type_enum: TxnType.Payment,
                        TxnField.amount:App.globalGet(Amount),
                        TxnField.sender: Global.current_application_address(),
                        TxnField.receiver: App.globalGet(Seller_Address),
                    }
                ),
                InnerTxnBuilder.Submit(),
            )
        )
        return ElseIf(App.globalGet(PurchaserApprove) ==Int(0)).Then(
        Seq(
                InnerTxnBuilder.Begin(),
                InnerTxnBuilder.SetFields(
                    {
                        TxnField.type_enum: TxnType.Payment,
                        TxnField.amount:App.globalGet(Amount),
                        TxnField.sender: Global.current_application_address(),
                        TxnField.receiver: App.globalGet(Purchaser_key),
                    }
                ),
                InnerTxnBuilder.Submit(),
            )
        )

This is part of my contract where payment receiver changes on INT flag. Not sure what I am missing since its not working.

If anyone can help.


post by fabrice on Nov 17, 2021

What did you try to run this smart contract? (the goal commands you run on command line, or the Python/Java/JS/Go script using the SDK that you used)

What exactly where you expecting?

What did you get? (the exact error message or the link to transactions on a blockexplorer that did not do what you want)

PS: I’ve switched the quotes ‘’’ into triple backquotes ``` (this is a different key on the keyboard) to allow proper formatting.


post by nikitagugale on Nov 19, 2021

It worked I missed parent seq() before If else condition.