Hi everybody. I’m neophyte about teal and smart contract and I do not understand why I am getting the error above. Can someone help me? Thanks!
#pragma version 5
//check on creation
int 0
txn ApplicationID
==
bz not_creation
global GroupSize
int 2
==
gtxn 0 TypeEnum
int appl
==
&&
gtxn 1 TypeEnum
int pay
==
&&
not_creation:
int 1
return
The logic is explicitly checking that the GroupSize is 2, however after you deploy the smart contract you seem to be submitting a single transaction rather than a group of 2, so it’s failing.
You’d need to send a group transaction where the first transaction is the application call and the second transaction is a payment.
If you’re using goal you can do something like this:
Ah OK, so there’s potentially two routes here. Typically you would branch to a int 1; return during deployment, but you appear to have it setup so that you jump to the not_creation only after it has been deployed. So this means that during deployment you are expected to submit the deployment in a group transaction that also includes a payment transaction.
So it depends what you want to happen. Should it be checking the group size and payment transaction on deployment or on subsequent calls after deployment?
Here’s a working example assuming you want to deploy the contract, then subsequent calls require a group.
#pragma version 5
// Deploy?
txn ApplicationID
int 0
==
bnz deploy
global GroupSize
int 2
==
gtxn 0 TypeEnum
int appl
==
&&
gtxn 1 TypeEnum
int pay
==
&&
assert
deploy:
int 1
return