Esempio n. 1
0
        [Txn.on_completion() == OnComplete.DeleteApplication,
         Return(Int(0))],  # block delete
        [Txn.on_completion() == OnComplete.CloseOut,
         Return(Int(1))],
        [Txn.on_completion() == OnComplete.OptIn, handle_optin],
        [
            Txn.application_args[0] == Bytes("set_permission"),
            set_permission_contract
        ],
        [Txn.application_args[0] == Bytes("issue"), issue_token],
        [Txn.application_args[0] == Bytes("kill"), kill_token],
        [Txn.application_args[0] == Bytes("transfer"), transfer_token],
        [Txn.application_args[0] == Bytes("force_transfer"), force_transfer])

    return program


if __name__ == "__main__":
    params = {
        "TOKEN_ID": 11,
    }

    # Overwrite params if sys.argv[1] is passed
    if (len(sys.argv) > 1):
        params = parse_params(sys.argv[1], params)

    print(
        compileTeal(approval_program(params["TOKEN_ID"]),
                    Mode.Application,
                    version=3))
Esempio n. 2
0
                     Txn.group_index() == Int(0),
                     Txn.type_enum() == Int(4),
                     Txn.asset_amount() == Int(0))

    pay_gold = And(Txn.type_enum() == Int(4),
                   Txn.sender() == arg_sender,
                   Txn.asset_amount() <= asset_amt)

    combine = Or(asa_opt_in, pay_gold)

    return combine


if __name__ == "__main__":

    #replace these values with your customized values or pass an external parameter
    scParam = {
        "ARG_SENDER":
        "M7VR2MGHI35EG2NMYOF3X337636PIOFVSP2HNIFUKAG7WW6BDWDCA3E2DA",
        "ASSET_AMT": Int(1000)
    }

    # Overwrite scParam if sys.argv[1] is passed
    if (len(sys.argv) > 1):
        scParam = parse_params(sys.argv[1], scParam)

    print(
        compileTeal(
            gold_asc(scParam["ASSET_AMT"], Addr(scParam["ARG_SENDER"])),
            Mode.Signature))