Hi guys, I have contract1 with add method:
@app.external
def add(a: abi.Uint64, b: abi.Uint64, *, output: abi.Uint64) -> Expr:
"""Add a and b, return the result"""
return Seq(
app.state.counter.set(a.get() + b.get()),
output.set(app.state.counter),
)
How can i call add method in contract1 from another app contract2?
I see that i can use Inner transaction
I try this, but it doesn’t work
from beaker import *
from pyteal import *
import calculator
c2c_app = Application("Inner")
@c2c_app.opt_in
def opt_in() -> Expr:
return Approve()
@Subroutine(TealType.none)
def inner_add(c: abi.Uint64, d: abi.Uint64) -> Expr:
return Seq(
InnerTxnBuilder.Begin(),
InnerTxnBuilder.MethodCall(
app_id=Int(262879086),
method_signature=calculator.add.method_signature(),
args=[c,d],
),
InnerTxnBuilder.Submit(),
)
@c2c_app.external
def c2c_add(a: abi.Uint64, b: abi.Uint64) -> Expr:
return inner_add(a, b)
if __name__=="__main__":
c2c_app.build().export("./artifacts2")