Teal version mismatch

Hi everyone,

I’m writing my very first SC in algorand. Started with Teal3, since it has some new opcodes and global vars, but I got “version mismatch” error when debugging… Then, I switched to Teal2. But still, the same problem occurs when I try to debug the code.

Simple stateful Smart Contract in Teal2, which saves app creator:

#pragma version 2
int 0
txn ApplicationID
== //
bz not_creation
byte "Creator"
txn Sender
app_global_put
int 1
return
bz failed
not_creation:
byte "Creator"
app_global_get
txn Sender
== //
bz failed
int 1 
return
failed:
int 0 
return

Command creating the app: goal app create --creator <ACCOUNT> --approval-prog ./creator2.teal --global-byteslices 1 --global-ints 2 --local-byteslices 3 --local-ints 4 --clear-prog ./clear.teal --out=dump2.dr --dryrun-dump

Debug command: tealdbg debug creator2.teal -d dump2.dr

Results:

Debug error: 11 errors:
1: version mismatch: assembling v2 with v0 assembler
4: field ApplicationID available in version 2. Missed #pragma version?
5: == arg 0 wanted type any got None
6: bz opcode was introduced in TEAL v2
9: app_global_put opcode was introduced in TEAL v2
11: return opcode was introduced in TEAL v2
12: bz opcode was introduced in TEAL v2
15: app_global_get opcode was introduced in TEAL v2
18: bz opcode was introduced in TEAL v2
20: return opcode was introduced in TEAL v2
23: return opcode was introduced in TEAL v2

If I run creator SC for Teal3 (https://github.com/algorand/smart-contracts/blob/master/devrel/teal3/creator.teal), then I get this:

    Debug error: 16 errors:
1: version mismatch: assembling v3 with v0 assembler
4: field ApplicationID available in version 2. Missed #pragma version?
5: == arg 0 wanted type any got None
6: bz opcode was introduced in TEAL v2
9: app_global_put opcode was introduced in TEAL v2
11: field GlobalNumUint available in version 3. Missed #pragma version?
14: field GlobalNumByteSlice available in version 3. Missed #pragma version?
17: && arg 0 wanted type uint64 got []byte
18: field LocalNumUint available in version 3. Missed #pragma version?
22: field LocalNumByteSlice available in version 3. Missed #pragma version?
25: && arg 0 wanted type uint64 got None
26: bz opcode was introduced in TEAL v2
31: global CreatorAddress available in version 3. Missed #pragma version?
33: bz opcode was introduced in TEAL v2
35: return opcode was introduced in TEAL v2
38: return opcode was introduced in TEAL v2

I guess the problem for both is that my algo node environment works for Teal V1. How do I change that, any ideas?

Thanks in advance!

Which version of goal are you using?
Can you run goal version -v and goal node status?

PS: I’ve edited your post and change the simple backquote to triple backquotes to format the text better.

Hey,

goal version -v

Version: [v1 v2]
GenesisID: testnet-v1.0
Build: 2.5.5.stable [rel/stable] (commit #304815d0)

goal node status

Last committed block: 1907274
Time since last block: 3.8s
Sync Time: 64648.1s
Round for next consensus protocol: 1907275
Next consensus protocol supported: true
Last Catchpoint:
Genesis ID: testnet-v1.0
Genesis hash: SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=

The machine is Ubuntu 20.04.2. I followed docs “Run a node”, which installed mainnet network and then I switched to testnet by replacing genesys file…

P.S. Thanks for editing, so triple backquote was what I needed. :slight_smile:

I have a different scenario with a sandbox on a Windows machine.

goal version -v

Version: [v1 v2]
GenesisID: sandnet-v1
Build: 2.5.5.stable [rel/stable] (commit #304815d0)

goal node status

Round for next consensus protocol: 2641
Next consensus protocol supported: true
Last Catchpoint:
Genesis ID: sandnet-v1
Genesis hash: 2nnIGT/c+wuwSeR+NAPXDV/XkJCBnrxf8ccR9xlRXfg=

If I debug Teal V2 program: tealdbg debug creator2.teal
Erorr: Debug error: 1 error: 1: version mismatch: assembling v2 with v3 assembler

From my understanding Teal is compiled with V3 in this case… Even though the goal version says v1, v2. (on both, ubuntu machine and sandbox).

How do I control this? I haven’t run goal version individually. It is running with tandem algod.

Can anyone explain why my posts were flagged and became hidden? I removed the links from the Goal command responses if that was the reason…

The spam detection system got a bit overzealous…

Regarding your problem, it is possible (but I may be wrong) that tealdbg only supports the latest TEAL version, that is TEAL v3.
Just switch to #pragma version 3.

It is safe to switch from TEAL v2 to TEAL v3 without changing the code.
Note that it is not safe to switch from TEAL v1 to TEAL v2.

1 Like

This time it worked. Not sure what was the problem exactly, cuz I tried V3 with approval program. Could be the fix was adding #pragma version 3 to clear program as well. Anyway, thanks for help!

The reason I started debugging this example, is different error I am getting from SDK when sending transaction to the network. Shall I post it here or open a new post for it?

Yes, you may need both the approval and the clear program to be in version 3.

Please create a new post for the other error.

1 Like