# I was trying to create and deploy a smart contract using pyTEAL following the official guide, but something went wrong

**URL:** <https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913>\
**Category:** Uncategorized\
**Created:** [November 1, 2021, 1:41pm UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913 "2021-11-01T13:41:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![taranchik](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@taranchik](https://forum.algorand.co/u/taranchik)\
**Post date:** [November 1, 2021, 1:41pm UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913/1 "2021-11-01T13:41:00Z")

</div>

I was trying to create and deploy a smart contract using pyTEAL following the official guide, but something went wrong…

> **[PyTeal — Writing Algorand Smart Contracts in Python](https://medium.com/algorand/pyteal-writing-algorand-smart-contracts-in-python-acfd7f7a48dd)**
>
> PyTeal is a python language binding for Algorand Smart Contracts (ASC) that abstracts away the complexities in writing smart contracts…

 ![image](https://us1.discourse-cdn.com/flex016/uploads/algorand/original/2X/2/2f9e39ef17fa7bccb1d7242aff08e71e1cfcbc85.png)

---

<div class="post-metadata">

**Author:** ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)\
**Post date:** [November 1, 2021, 9:24pm UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913/2 "2021-11-01T21:24:16Z")

</div>

Welcome to Algorand!

Can you provide the exact commands you typed as well as the content of all the relevant files (including `peridic_payment_deploy.py`?)

Write code and bash commands between triple backquotes ``` for better formatting.

---

<div class="post-metadata">

**Author:** ![taranchik](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@taranchik](https://forum.algorand.co/u/taranchik)\
**Post date:** [November 2, 2021, 4:33am UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913/3 "2021-11-02T04:33:53Z")

</div>

I just typped

> python3 peridic\_payment\_deploy.py

and that’s it

---

<div class="post-metadata">

**Author:** ![taranchik](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@taranchik](https://forum.algorand.co/u/taranchik)\
**Post date:** [November 2, 2021, 4:56pm UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913/4 "2021-11-02T16:56:48Z")

</div>

The content of the file is the same as in the guide

---

<div class="post-metadata">

**Author:** ![danger\_dave](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@danger\_dave](https://forum.algorand.co/u/danger_dave)\
**Post date:** [November 2, 2021, 5:04pm UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913/5 "2021-11-02T17:04:23Z")

</div>

Perhaps this is it?

```auto
#!/usr/bin/env python3

from pyteal import *
import uuid, params, base64
from algosdk import algod, transaction, account, mnemonic
from periodic_payment import periodic_pay_escrow

#--------- compile & send transaction using Goal and Python SDK ----------

teal_source = periodic_pay_escrow.teal() 

# compile teal
teal_file = str(uuid.uuid4()) + ".teal"
with open(teal_file, "w+") as f:
    f.write(teal_source)
lsig_fname = str(uuid.uuid4()) + ".tealc"

stdout, stderr = execute(["goal", "clerk", "compile", "-o", lsig_fname,
                          teal_file])

if stderr != "":
    print(stderr)
    raise
elif len(stdout) < 59:
    print("error in compile teal")
    raise

with open(lsig_fname, "rb") as f:
    teal_bytes = f.read()
lsig = transaction.LogicSig(teal_bytes)

# create algod clients
acl = algod.AlgodClient(params.algod_token, params.algod_address)

#Recover the account that is wanting to delegate signature
passphrase = "patrol crawl rule faculty enemy sick reveal embody trumpet win shy zero ill draw swim excuse tongue under exact baby moral kite spring absent double"
sk = mnemonic.to_private_key(passphrase)
addr = account.address_from_private_key(sk)
print( "Address of Sender/Delgator: " + addr )

# sign the logic signature with an account sk
lsig.sign(sk)

# get suggested parameters
params = acl.suggested_params()
gen = params["genesisID"]
gh = params["genesishashb64"]
startRound = params["lastRound"] - (params["lastRound"] % 1000)
endRound = startRound + 1000
fee = 1000
amount = 2000
receiver = "ZZAF5ARA4MEC5PVDOP64JM5O5MQST63Q2KOY2FLYFLXXD3PFSNJJBYAFZM"
lease = base64.b64decode("y9OJ5MRLCHQj8GqbikAUKMBI7hom+SOj8dlopNdNHXI=")

print(params["lastRound"])
print(startRound)
print(endRound)

# create a transaction
txn = transaction.PaymentTxn(addr, fee, startRound, endRound, gh, receiver, amount, flat_fee=True, lease=lease)

# Create the LogicSigTransaction with contract account LogicSig
lstx = transaction.LogicSigTransaction(txn, lsig)

# write to file
txns = [lstx]
transaction.write_to_file(txns, "p_pay.stxn")

# send raw LogicSigTransaction to network
txid = acl.send_transaction(lstx)
print("Transaction ID: " + txid)

```

---

<div class="post-metadata">

**Author:** ![taranchik](https://avatars.discourse-cdn.com/v4/letter/t/e36b37/32.png) [@taranchik](https://forum.algorand.co/u/taranchik)\
**Post date:** [November 2, 2021, 5:17pm UTC](https://forum.algorand.co/t/i-was-trying-to-create-and-deploy-a-smart-contract-using-pyteal-following-the-official-guide-but-something-went-wrong/4913/6 "2021-11-02T17:17:49Z")

</div>

Yeah, exactly. That is the content of

> peridic\_payment\_deploy.py

. I’m running in the meantime Algorand node locally on my machine.
