Is there a way to increment b256?

For example, initially, the sub_id is 0x…0000. I can save the sub_id in storage. When I mint again. contract wiil increment sub_id to 0x…0001. So I can make sure the sub_ids are different for different native tokens.

1 Like

At this time, I don’t think there’s any simple way of incrementing a b256, our plan is to add a u256 integer, which can be incremented and converted to a b256. This can be tracked in this issue:

In the meantime, you can use the following work-around:

let my_u64 = 10;
let tuple = (0, 0, 0, my_u64);
let my_b256 = asm(r1: tuple) { r1: b256 };

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.