Logic eval error: invalid Box reference #1571
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 15 replies
-
You are providing the map index of |
Beta Was this translation helpful? Give feedback.
-
As Jay mentioned, when providing the boxes for the remote call, you also have to take into consideration any Set that was referenced within the remote call. In my case I had used a Set and a Map within my API block, In the remote call I was expected to provide the boxes for both the Set referenced and the Map, as Sets are actually Maps too. But I was toggling between indexes Thanks to Jay, I have come to understand the right way to supply the boxes needed for a remote call. First discern how many boxes were referenced, be it a Set that was only used to check if a particular address is a member, or a simple property lookup in a Map. Then take note of the order these Sets and Maps were defined in the oracle contract, and not how they were referenced within the call. For the first Map or Set defined in the oracle contract, that would have an index of Then also take note of the keys used for referencing these Sets or Maps within the remote call, these would serve as the key of the box. Now after noting all that is necessary... You pass in the information to the REMOTE_FUN.ALGO({
fees: IntegerValue,
assets: [TokenValue, ...Any other referenced tokens],
accounts: [AddressValue, ...Any other referenced account],
boxes: [[ContractValue, Map Index, Map Key], ...Any other referenced box]
})(...args) Here's an example of such a call: remoteFuncs.Foo_Bar.ALGO({
fees: 1,
assets: [token],
accounts: [D, user_1, user_2],
boxes: [
[mainContract, 0, D],
[mainContract, 1, user_1],
[mainContract, 1, user_2],
],
})(D, user_1, user_2) In this example, a fixed fee amount is provided, in case the calculated fee exceeds that of the flat fee. Assets was provided because in my consensus block I made a transfer of that token. In the above example, Then The Set used as a reference for the first account, Next, the other accounts, With a setup such as this, it is important to note:
check(isSome(map[address]), 'Not a member') Instead of check(set.member(address), 'Not a member') As this would save you the amount of boxes you would need to provide the boxes opt field of the This is because, the Application step with the remote call may end up using more transaction references than the limit allows if not properly managed. I hope this makes your next use of remote functions easier.
|
Beta Was this translation helpful? Give feedback.
You are providing the map index of
0
, but it looks like it is actually1
. The map index is the order it appears in the program. So the first one is0
and the second is1
and so on.