Hey,
I’m able to call other functions in other application, however, there is this one function that I’m trying to call many times but its always giving a different error, when I remove the args from this call and simply call the function by giving its name then it gave me the error "pushBytes “distribute-tax” etc
Received status 400: TransactionPool.Remember: transaction SSWTELQGZ3C42C3FQZZWKJLPS3Q6DQXYFTGFN4M2C4R6H77SL6JA: logic eval error: logic eval error: assert failed pc=541. Details: pc=541, opcodes=app_global_get
==
assert
. Details: pc=221, opcodes=load 1
itxn_field ApplicationArgs
itxn_submit
This is the error that I’m receiving whenever I call the distributeTax function of my TaxContract from the PrimaryContract
Here is the code of my PrimaryContract
from pyteal import *
def approval_program():
@Subroutine(TealType.none)
def call_tax(token):
return Seq([
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.ApplicationCall,
TxnField.application_id: Int(105162470),
TxnField.on_completion: OnComplete.NoOp,
TxnField.application_args: [Bytes("distribute-tax"), token],
}),
InnerTxnBuilder.Submit(),
])
_token = Txn.application_args[1]
on_call_tax = Seq([
# is_application_admin,
call_tax(_token),
Approve(),
])
on_call_method = Txn.application_args[0]
on_call = Cond(
[on_call_method == Bytes("call-tax"), on_call_tax],
)
on_delete = Seq([
Approve(),
])
on_update = Seq([
Reject(),
])
program = Cond(
# Application Creation Call would be routed here.
[Txn.application_id() == Int(0), on_creation],
# All General Application calls will be routed here.
[Txn.on_completion() == OnComplete.NoOp, on_call],
# Reject DELETE and UPDATE Application Calls.
[Txn.on_completion() == OnComplete.UpdateApplication, on_update],
[Txn.on_completion() == OnComplete.DeleteApplication, on_delete]
)
return compileTeal(program, Mode.Application, version=6)
print(approval_program())
This is how my TaxContract looks like:
@Subroutine(TealType.none)
def distribute_tax(token, origin):
return Seq([
// Transfer tokens to the some other account;
])
_token = Btoi(Txn.application_args[1])
on_distribute_tax = Seq([
is_application_admin,
distribute_tax(_token, Txn.sender()),
Approve(),
])