broadcast asset request and allow first reply to send asset

+1 vote
Hi,

I'm new to multichain, so I wanted to ask how i can make the following scenario work with it:

I'd like to issue a known quantity of a particular asset (e.g. 100 of asset1). My understanding is that all the nodes in the system will be aware that 100 of asset1 exist in the system

When a node comes up, I'd like to make a broadcast request for 1 unit of asset1. I'd like a node to reply and send that 1 unit over. When a node is about to go down, i'd like to send that 1 unit of asset1 back into the system.

Maybe assets aren't the right thing to use, and maybe data streams are. But some thoughts and guidance would greatly be appreciated.

Thank you
asked Feb 3, 2017 by jahluwalia

1 Answer

0 votes

You could naturally use data streams to broadcast the request (with other nodes monitoring the stream's contents using APIs like liststreamitems with local-ordering=true) but the item to be transferred should indeed be an asset. However please note that the blockchain can't itself enforce the return of an asset when a node is about to go down. Either the node would have to take care of that itself, or else the asset would need to be locked under some kind of 1-of-2 multisignature scheme which allowed its forcible return.

answered Feb 5, 2017 by MultiChain
Thank you for your reply. Could you break it down a bit further for me? For example, the node that comes up....what api call should he make to broadcast request an asset. Then on the receiving side of that request, to the nodes that have subscribed to the asset, how what API call can they make to send the asset to the requester and how can I be assured that only one node does indeed send it?

On the return side, I think I can handle at the application level when it is about to go down. The question becomes who should he send the asset back to? As the one he may have gotten it back from may no longer be there.

Thank you for your help.
Just to clarify, in my original example of 100 of asset1. I don't know if there is a particular owner. I just want all the nodes to be aware that 100 of asset1 exist. Then when a node comes up, it requests an asset (broadcast?) and is given one. Then the system is aware that 99 now exist. This goes on until there are no assets, at which point the 101'th node would be told "no more assets exist, you cannot come up." I'm just not clear on what api calls I can make to do this. Thanks
Can I recommend you start by going through the 'Getting Started' tutorial? It will give you a sense of how to perform these sorts of operations on MultiChain.

http://www.multichain.com/getting-started/
Hi,

Thank you for the link but I had actually gone through getting started link as well as the api, and native assets, before asking the original question. I've probably just confused myself,  so maybe an analogy will help clarify my position. Let's say a node represents a person in a theme park. Only 100 people are allowed in this park at a time. When a person comes to the gate (e.g. Comes online or machine turned on), he is given a ticket. But there is no ticketing office, he jusr yells over the gate "hey can I have a ticket?" The closest person or first person to hear him goes "there are 20 ppl in here, so sure." And hands the newcomer a ticket and then tells everyone else "there are 21 ppl in here! I just gave out ticket #xyz."

When someone leaves the park (e.g. Machine turns off) he just says "I'm leaving, here is my ticket #xyz back." Then the first person to hear that tells everyone "hey, that guy left. I put his ticket back. There are 20 ppl here"

 Here are some differences to the scenario I'm proposing to what's in the getting started guide and what I saw in the API (and I could be thinking about this the compete wrong way, so please put me on the right track based on the analogy if the below doesn't make sense):

1) in the guide I only saw how to send an asset, but not how to request one (person asking for a ticket). Is that supposed to happen in the application  layer? something I wanted to avoid
2) and in terms of requesting an asset, how can I request it from anyone? As opposed to a requesting from a specific address? (Hey anyone, can I have a ticket?) Again, at the application layer? Something I wanted to avoid
3) global wallet of asset "ticket".  Is this possible? I want 100 units of ticket to be issued, but without an owner. So any node knows how many of the 100 are left and any node can send tickets from the shared pool. Each time a node comes up, it receives one unit of asset ticket.
3) there is not a single node I want to request the asset ticket from. The asset can come from anyone that has access to that global asset of ticket I mention above. So what mechanism do I use for sending 1 unit of asset ticket and making sure only 1 is sent to the new node that came online.



Thanks
Jas
1+2) Requesting for an asset could be implemented as a message over a stream, to which any node is able to subscribe.
3) A global wallet can be implemented by sharing the private key between all nodes who should have access to that wallet (use dumpprivkey + importprivkey). But in that case, why not just have new nodes take the token for themselves, rather than waiting for someone else to send it? That would also solve the problem of the ticket being sent by more than one node.
...