This document contains tips and issues of smart contract development and should collect all the things we need to take care of when writing a smart contract.

We have to import this line in the first line of the smart contract code

from inception_tests.common.common_imports import *

P.S. this line is only IDE-friendly and will be removed after the render procedure.

“FROM“ imports are not allowed when creating a smart contract

We can only do import ... as alias.

Usage of classes (OOP) is not allowed in smart contracts

We can only define modules and functions and write code as procedural programming. Smart contracts are “state less”.

Fetching current balances in supervisor post posting hooks

Supervisor post postings hooks have a common bug (Thought machine internal bug), where when fetching the current balances of supervisee accounts, which were affected by postings received to the post_posting hook (postings that triggered the supervisor run itself)), the balances might not be updated to reflect the change that also the accepted posting caused.

To prevent this bug, we fetch affected current balances in supervisor as the last value before current effective_date + effect of incoming postings.

See https://github.com/SafiBank/SaFiMono/pull/7710 for further details.