Smart Contracts in SAFE


What is the best way for smart contracts be implemented in the SAFE network?

Seems to me that, with trust handled by the network, it would be redundant to use Ethereum and its blockchain.

So what is the best smart contract scripting language, sans blockchain. Maybe plain old Python would work, nothing exotic, and it saves many people from learning something new.

How are smart contracts, or their execution, incentivized? (if that’s the right term). At the app level? Seems to me that if a new smart contract is sitting in a folder, and has a memorable (DNS) name, and has the advantage of novelty, then many people would GET it, over and over, and the owner of the smart contract or the folder is in the role of an app developer. The smart contract’s execution would be handled where? It has to be somewhere where the owner of the processor has some incentive. The smart contract is a (maybe a very small) app.

I hope that’s not too vague!


It’s a good question . I am looking forwards to read diverse answers & ideas … :ant:

Oh, a better idea: A free library of thousands/millions of templates of smart contracts, for anyone to access and fill in the details of each smart contract. That is the site, if not app, that is monetizable.


It’s an underdeveloped field, to put it mildly. I found a tutorial: and the platforms they list are mostly either blockchain-based or the sites are down. One, Bithalo, looks interesting.

Everyone thinking about smart contracts appears to either doing it on a blockchain or building trust into the client. A client that leaves trust to the SAFE network, is an open field.


Not 100% here but I think @dallyshalla who is building safexchange will have smart contracts available. I’m not sure what kinds or how many but he may be able to elaborate


Another possibility is to just wait until distributed computing is implemented on SAFE, then there could be a business resident on SAFE, call it Multivac*, which does nothing but execute smart contracts in exchange for Safetcoin micro-payments (or a subscription, or freemium model)

*After the famous, world computer of the Asimov story.


Check out


I really like the term Safe Contract :wink: from the doc linked. I am so hoping we will see smart contracts on safe. There has been talks about eventual processing and when that happens things will get very interesting.


The one thing Ethereum has that SAFE does not is time.


Could you please elaborate?

The SAFE Network can not tell time. It would be difficult to make certain contacts without the concept of time.

1 Like

The link from Irvine seems to imply that the network will not track time, but any number of additional apps or layers could easily implement a time stamp, etc…I would not lose any sleep over it, it is a needed function that someone (probably many someones) will certainly take care of.


Ah! Thanks for that reference!

Permit me to ponder this.

Computers (or at least, Von Neumann computers like we normally use) need clocks in order to exist. No clocks: no distributed computing.

What are clocks, anyway? Machines that count, along the natural number sequence: 1, 2, 3, 4… That’s all! We moderns lose sight of the fact that our basic, most primitive clock, the thing that gave us clockness, is the solar day: sun comes up, sun goes down, over and over.

Another primitive clock that we take for granted is the human heartbeat. And indeed, electronic system are sometimes spoken of as having a heartbeat.

We imagine that time is some fundamental quality of the universe, and not just the ticking of machines that might be speeding up or slowing down. By what standard? How would we know?

What matters is that the order of events be recorded reliably, and not that they have to be some objective distance apart on some universal metric.

So, one could imagine “blockchain time” where each added block is a “tick.” It goes indisputably in one direction. Like entropy, but different.

Given these blockchain time reference ticks, one might set ones local clock to them in order to divide the ticks into subunits.

We don’t want an actual blockchain, but we might hope to employ some persistent and uni-directional process that already exists as a necessary function within the network, like a heatbeat, that everyone at least occasionally touches bases with, and to which they could set their local clock. A ticking thing like a blockchain that doesn’t happen to be a blockchain. For example, might the Kademlia hash table serve such a purpose?


completely true , the reference of “time” within the safenetwork can be tied to something that isn’t specifically Time itself but something acting as a clock or counter , or anything as a reference for the contract.

I think smart contracts are being pushed as this magical make the impossible possible technology that mean a teleport to the fast lane of technological advancement and creation . when in their current form they are incredibly limited , taking them outside of the blockchain, basing a contract on an event outside of the blockchain means you remove objectivity from the system and also push consensus to outside of that blockchain , making it very easy to manipulate and control .

Augur might experience the problems first , They have a reputation system that gives people the power to decide how certain events took place , these decisions cannot be based inside of the blockchain they have to be provided from the outside , so the mechanics and objectivity of the system they are built in is entirely ignored because their information which can easily be manipulated is required from outside said system.

Now with augur , their system depends on the most voted for option , If 4-5 people own 51% of the coin they can attack the system, they can report wrongly on events , what’s more is they are incentivized to do so, 99-100% voting on 1 option shares the profits with everyone that has reported, if 51% vote for the wrong option but because it is over 50% it counts as the right option , they have increased their profits by almost 100%(from fee’s collected) plus they can steal reputation from everyone who reports on events correctly(but the system thinks incorrectly) giving them a higher % share of the reputation reporting system.

Now this might not happen , depending on how well augur is shared out among the masses, but each crypto currency we have seen has seen large majorities of holdings in a very small amount of addresses , Or hoarding on exchanges (which could report events themselves with everyone elses voting rights) So it may not happen and could just be another wild random speculation of what “could” happen in the future but never does actually happen but it serves as an example of smart contracts in blockchains and the fact that they need a consensus that is outside of the decentralized consensus of the blockchain they created, that consensus will be massively centralized and much easier to fool , trick , lie and cheat.

Edit : just to note , they are incentivized to report the wrong data , giving them the ability to claim more “fee’s” but by doing so would effectively destroy the system making their investment and the augur platform completely useless for the thing it was built for, so there would be a huge loss to investment and worth if it was to be done and is unlikely to happen as such


There are many interesting points to address in this post. Given the fact that I am currently writing a system which uses the SAFE network to implement ‘Smarter’ contracts and many other additions, I think I can shed some light into the dark here. :slight_smile:

This is also the first time I am publically speaking about the project because currently I am not sure whether to make what I’ve written a SAFE fork or an application - It depends largely on funding and right now and compensation for App developers and how that works.

So the best language to form a contract I believe is not the language defined by Ethereum. In fact, I believe smart contracts on the Ethereum blockchain are much too restrictive - they were designed to operate on and with what the blockchain can provide.

The solution I’m working on is a decentralised data flow language which uses proofs to indicate program operation as well as dimensions which control the dimensionality of the data in order to constrain the size of the input / data produced. The programs themselves are incentives for peers because they are used to obtain specific data from specific nodes. At this point and given the fact that SAFE has no notion of computation, the cost of someone else computing something for you is determined by the cache produced by the program executed - which essentially contains the entire state of the program compressed.

On time and clocks. I think these two concepts are actually very separate. Time refers to real world time which benefits from decentralisation in the sense that time is decentralised anyway. The time here in Trinidad is completely different than the time in Toronto or the US, where someone else may be located. Clocks however are used to synchronize computations along particular axes and can be part of the underlying programming model (hence synchronous programming). I won’t go into the full details of the solution but basically, think functional reactive programming in a decentralised setting.


IIRC There is a much higher-view roadmap that @dirvine is following:

  1. Network (testnet is now up as proof of that)
  2. Safecoin (is coming soon - kinda bundled into the Network, but I differentiate it)
  3. Distributed computation
  4. Smart contracts (dependent on #3)
  5. SafeOS

EDIT: It’s kinda funny, I always imagine that 1, 3, and 4 kinda make up a computer analagous to Storage, Processing, and RAM respectively. Kinda follows that an OS would be built to leverage that…


So I think its necessary here to make a distinction between ‘Smart Contracts’ as coined by Ethereum and ‘Programming Contracts’ which are a lot more sophisticated and depend on SAFE CPU. The Ethereum based smart contracts are not dependent on the CPU as a resource aspect of the SAFE network (which is what you are suggesting here in 4 where you say they are dependent on distributed computation which is not the case). In fact it would be detrimentary to write such contracts on anything else than a blockchain since they relate only and very specifically to the attributes of accounts holding crypto currency.

You can think of it this way: MAID is a resource which buys you disk, ETH is a currency which buys you time on a decentralised blockchain to execute smart contracts. Ethereum smart contracts on SAFE = blockchain on SAFE as a prereq.

1 Like

Well, it is…sort of. Certainly Einstein’s idea of Spacetime forms the basis of many different scientific /mathematical concepts. I pondered about this aspect a bit in regard to the Safe Network. At first I was thinking “Noooooo…DIrvine’s missed out the 4th dimension…the Safe Universe won’t work!”
It then dawned on me that “Time” is only necessary for record keeping. Safe isn’t designed for record keeping, or rather it’s not an inherent property of it. This does not preclude any innovative Dev from introducing the “4th dimension” to the “Safe Universe” and see what thought experiments ensue, what possibilities arise and what interesting further ideas it leads to…as Einstein did. :smile:


RAM is just a faster storage. As processor registers are faster than RAM.

Physically, there is only one dimension in computing - a stream of bytes :slight_smile: And you can code any dimension number you want, for example thousands-dimensional matrices used in neural networks.