TinyChain Platform

Python client introduction

Python API documentation: https://tinychain.readthedocs.io/

Install the client

The easy way to install TinyChain's Python client is using Pip:
# on newer operating systems this command may be "pip" instead of "pip3"
pip3 install tinychain

Hello, World!

You can verify that you've installed the Python client correctly by running this Hello, World! program:
import tinychain as tc
# This host is available for demonstration purposes, but may be slow
# due to the volume of requests it receives.
HOST = tc.host.Host("http://demo.tinychain.net")
# This endpoint will attempt to execute resolve whatever State it receives,
# without committing any write operations.
ENDPOINT = "/transact/hypothetical"
def hello(name: tc.String):
return tc.String("Hello, {{name}}!").render(name=name)
if __name__ == "__main__":
cxt = tc.Context()
cxt.hello = hello
cxt.result = cxt.hello("World")
print(HOST.post(ENDPOINT, cxt))
If you have any trouble with the host at demo.tinychain.net, you can run your own host by following the steps in Install TinyChain.