I have a question about the internal invocation of a single contract to other contracts and would like to consult.
Figure1
Such as figure1
Using InnerTxn to call different methods of multiple contracts by calling A single method inside contract A, here is the simple logic of the A contract:
A Contract function about InnerTxn - AppCall
# call B contract bbb
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.ApplicationCall,
TxnField.application_id: App.globalGet(global_b_contract_id),
TxnField.on_completion: OnComplete.NoOp,
TxnField.accounts: [Txn.accounts[1], Txn.accounts[2]],
TxnField.application_args: [Bytes("bbb"), b_address],
TxnField.fee: Int(0)
}),
# call C contract ccc
InnerTxnBuilder.Next(),
InnerTxnBuilder.SetFields({
TxnField.type_enum: TxnType.ApplicationCall,
TxnField.application_id: App.globalGet(global_c_contract_id),
TxnField.on_completion: OnComplete.NoOp,
TxnField.accounts: [Txn.accounts[1], Txn.accounts[2]],
TxnField.application_args: [Bytes("ccc"), b_address],
TxnField.fee: Int(0)
}),
InnerTxnBuilder.Submit(),
Approve()
This is my script:
goal app call \
--app-id "$A_CONTRACT_ID" \
--app-account "$A_ADDRESS" \
--app-account "$B_ADDRESS" \
--from "$A_ADDRESS" \
--app-arg "str:call" \
--app-arg "addr:$B_ADDRESS" \
--foreign-asset "$ASSET_ID" \
--foreign-app "$B_CONTRACT_ID" \
--foreign-app "$C_CONTRACT_ID" \
--fee 6000
But I encountered error: Invalid Application ID reference.
I don’t know why I can’t do this
I tried to call the corresponding methods of B Contract and C Contract separately from the two methods inside A Contract. Like figure2
Only one --foreign-app parameter is kept, so the contract logic works normally.
My question is:
Do contract inner-transaction not support calling both contracts?