2

When a Client is creating a Message with an Indexation Payload, can it freely choose the tips/parent to which to refer?

Thanks.

2 Answers 2

1

Yes, you can manually specify the parent messages to which your new message refers. This is done by providing the parents field when creating the message. However, you should be cautious when doing this, as it may affect the confirmation of your message if the chosen parents are not optimal.

Here's an example of how you can create a message with an IndexationPayload and manually specify the parents in the Node.js library:

const { ClientBuilder } = require('@iota/client');

const client = new ClientBuilder().node('https://api.lb-0.testnet.chrysalis2.com').build();

(async () => {
  const indexationPayload = {
    type: 2,
    index: 'Hello',
    data: 'Tangle',
  };

  const message = await client.message().parents(['parent1', 'parent2']).payload(indexationPayload).submit();

  console.log('Message sent:', message);
})();

Replace 'parent1' and 'parent2' with the actual message ids of the parent messages you want to reference. Keep in mind that this example is for the Node.js library, and the implementation may vary for other languages.

Remember that manually specifying parents can be risky, and it's generally recommended to let the node handle tip selection for you.

Credit goes to Kapa.ai and IOTA&Shimmer documentation

1
  • 1
    Thank you so much, really helpful explanation. Commented May 25, 2023 at 16:20
1

The tips/parents are randomly chosen and I quote:

A node should keep a set of non-lazy tips (score 2). Every time a node is asked to select tips to be approved, it will pick randomly from the set. A node must not execute tip-selection if it is not synchronized.

A tip should not be removed from the tips set immediately after it was selected in select(), to make it possible for it to be re-selected, which in turn makes the Tangle wider and improves synchronization speed. A tip is removed from the tips set if X amount of direct approvers are reached or if a certain amount of time T passed. It is recommended to use X = 2 and T = 3 but the threshold should be configurable.

To find further information on this topic explore the TIP (Tangle Improvement Proposal) available here:

https://wiki.iota.org/tips/tips/TIP-0003/

Best, Antonio

1
  • 1
    Thanks. But what if a Client, during the Message creation, chooses a set of Messages to which refer to and propose them to the Node ? If the new Message that is creating has and Indexation Payload and the older Messages too this will not create any problem. I'm asking this because by theory should be legit (if I'm not wrong) but I don't know if this can be done through code implementation. Commented May 23, 2023 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.