Basic Computations in SmartPy, Python and Michelson
Jul 25 · 4 min read

Some basic requirements

Integers and Naturals

The Case of Addition, Multiplication and Subtraction

How Many Divisions ?


<eval a>
{ <eval b> }
{ PUSH bool False }

Control Operators

sp.if condition:
with sp.ifBlock(condition):
sp.for x in expression:
with sp.forBlock('var', expression) as var:
sp.while condition:
with sp.whileBlock(condition):

How do we ensure that this is correct?

import smartpy as spclass CheckOperator(sp.Contract):
def __init__(self, default, f, *args):
self.f = f
self.length = len(args)
self.init(result = default)
def run(self, params):
args = [getattr(params, "x_%i" % i) for i in range(0, self.length)] = self.f(*args)

Thanks to Charlie Wiser

Written by

An intuitive and effective smart contracts language and development platform for Tezos. In Python.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade