TinyChain Platform
  • What is TinyChain?
  • Guides
    • Getting Started
    • Python client introduction
    • Types and casting
    • Anatomy of an Op
    • Flow control: after, cond, while_loop
    • Closures and functional programming
    • Install a Library or Service
    • Code a compute graph
    • Debugging
    • Ask for help
  • Fundamentals
    • Install TinyChain
    • Technical Details
  • Advanced
    • Client-side Class Inheritance
  • Use Cases
    • For Engineers
    • For Data Scientists
    • For DevOps
    • For Product Owners & Executives
    • For End-Users
Powered by GitBook
On this page
  • Install the client
  • Hello, World!
  1. Guides

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"

@tc.get_op
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))
PreviousGetting StartedNextTypes and casting

Last updated 9 months ago

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