How a node can add data to the chain using python?

+2 votes
I want a site to add data to a blockchain using python, so how it can be done?

Thanks in advance
asked Nov 5, 2020 by anonymous

1 Answer

+2 votes

You can start with one of the Python libraries linked from the bottom of this page:

https://www.multichain.com/developers/

Then use it to access the publish API to put the data on the chain.

answered Nov 6, 2020 by MultiChain
Thanks for the response!!
I have made the blockchain using the python libraries mentioned but now I cannot figure out which function to call. I was trying to call stream method
restrictions={"restrict":"write"}
mychain.create('stream', 'stream5',restrictions)
#returns hash value
mychain.publish('stream5','key1',{"json":{"name":"John Doe","city":"London"}})
#returns hash value
But when I try to access the stream item it gives an error.

Please let me know where I am wrong or what's the alternative.
PS: OS is Windows 10

Thanks in advance
If you got hash values back for both calls, that's a good sign.

When you say "when I try to access the stream item it gives an error" what do you mean? Most likely, you need to tell the node to subscribe to the stream before querying it.
Thanks, I was not subscribing to the stream earlier. Got it  now!! Thanks for resolving the query.
...