Debugging
How to debug TinyChain code
import tinychain as tc
@tc.get_op
def add(a: tc.Int):
b = tc.Int(2) + tc.Int("foo")
return a + b
if __name__ == "__main__":
cxt = tc.Context()
cxt.op = add
cxt.result = cxt.op(2)
host = tc.host.Host("http://demo.tinychain.net")
print(host.post("/transact/hypothetical", cxt))Step 1: assign descriptive names
# ...
@tc.get_op
def add(cxt, a: tc.Int):
cxt.two = tc.Int(2)
cxt.foo = tc.Int("foo")
cxt.b = cxt.two + cxt.foo
return a + cxt.b
# ...Step 2: add validation
Step 3: turn on logging
Step 4: inspect program code as JSON
Step 5: ask for help
Step 6: run the host in debug mode
Last updated
Was this helpful?