Blockchain Vs Safe Network.(Smart Contracts)


#1

Hi

How is Safe Net better or worse than block chains at delivering smart contracts?

N.B

I would like to start a new Block chain Vs Safe Network topic each week. In which we can discuss a different application and start to build up good organized arguments for Safe. I think using block chains as a datum is useful as most people understand how they work.


Safe Smart Contracts
#2

I think a smart contract is just a fancy way of saying a piece of code running on servers/cloud.

In the case of blockchain, because each smart contract has to be run on every node of the blockchain, you can imagine how slow it will be. and it costs a lot.

For SAFE, I haven’t seen any concrete documents about how smart contracts are gonna work. But my guess is that because SAFE uses group consensus, so only nodes around that specific smart contract run the code. so it supposes to be faster, and cheaper.


#3

I have been thinking about how it would work. Actually, in not knowing if/how/when distributed computing would be part of SAFE net, I have been thinking about how some sort of shortcut could be produced.

The reason for this is that I develop applications which needs part of the execution to be performed by some “objective” host, i.e. simply running the code on clients would not work. That’s how I see it, there are things that cannot be programmed without some “objective” decisions available.
Consensus would be one way to reach objectivity.

My very naïve design ideas have been similar to how smart contracts run. But, as to avoid complicating the network, it would be a solution on the app level.
It would be interesting to hear if maidsafe people deem it reasonable/possible to go down that way.

Edit: spelling


#4

Think of multisig, which we have the machinery for but not enabled yet. So you have several data points (Mutable Data) which represent agreements of sorts. So App A agrees and sign’s an MD to do something (swap owners or whatever it is supposed to do, add comments, or change data etc.). It sends the signature (this is the part we have not agree on, this send signature part) but the MD will not change until App B agrees conditions are met. Then it to can sign the MD And it will change.

You can expand a lot on this pattern and have “smart contracts” a term that has become widely overused. I prefer to think of this as network agreed logic. In any case this is a huge area, but I think many folk will see this simplistic pattern above is the basis for smart multi level contracts that execute in a domino type effect but clearly so and can depend on in network “oracles” (another term I hate) or worst case out of network oracles (which I feel invalidates many contracts, smart or not).

Hope that helps.


Smart Contracts in MaidSAFE
#5

So potential positive angles for using Safe Net for contracts would be ;

  1. Faster contract creation.

  2. Faster execution of contract.

  3. Flexibility to write the contract in your preferred language from a developers point of view.

  4. Potentially cheaper than block chains

  5. Easy to integrate into a safe project.

Negatives

  1. Unable to run outside of the safe network.

  2. Unproven


#6

Yes.

Not really, an app could get outside network oracles, like ethereum does. I do not like these as the out of network could be insecure/hacked etc. Although I don’t like it, you can still do it via an app easily.

Yes :smiley:


#7

Thanks for taking the time @dirvine. I hope to make some videos eventually exploring Maidsafe Vs block chains so this feedback is great.


#8

Ok read all but still I have some questions, can someone please try to clear my confusions?

I understand the basic difference between blockchain and safenetwork now the issue is, blockchain stores each and every transaction of past and thus the space it takes increases exponentially depending on number of blocks mined and the number of nodes. It makes the process slow as well. Now I think safenetwork can (or at least eventually would) do everything a blockchain can do. The apps developed on safenetwork can eventually replicate every work of blockchain based system and they can (will) do a lot more. Does it mean that safenetwork would end the era of blockchain or can they grow simultaneously? I am really confused regarding this matter, maybe my concept is a little wrong but I would love to get some feedback and reply.

Thanks guys


#9

It would be nice to see Ethereum running on the Safe Network


#10

Don’t you think an app or something similar would be better which is solely based on Safe Network? It would be much more secure. Mixing up the traditional and Safe Network might be dangerous as per my view.


#11

Thanks for explaining this. I am sure it has been mentioned elsewhere, but I hadn’t thought of it in the context of smart contracts. I suppose when the action can be any data mutation through multisig, not just blockchain style, high cost, transactions, there is scope to use this design pattern far more.

Moreover, given anyone can run an agent on their device which simply automates responses, why bother with the complexity of blockchain VM code? If timing and redundancy was key, you could even set up several agents at different locations.

Digging deeper, this design pattern would also free you to use any software/scripting language you prefered. No need to muck about with special ethereum scripts or whatever. Furthermore, you can keep your keys safe and not trust them to run correctly in an unstoppable way.

Maybe this is just a better way of achieving the same goals as ethereum. It would be good for someone with more knowledge of ethereum to explain disadvantages of this approach.

Obviously, for distributed processing, it is a different problem entirely, but one that blockchains are not a great fit for anyway.


#12

In a post safe net world the only block chains I can see surviving are as a store of value. Why use a pager when you have cell phone.


#13

Have you seen this?


#14

That’s the beauty about SAFE we can actually run a lot of what these guys are doing and even traditional web business, cloud, IoT etc…


#15

Specifically the Smart Contracts section

As discussed in the multisig section, smart contracts are a hot topic in the world of blockchains, especially ethereum and rootstock.

Does safe support smart contracts?

Yes and no. The structured data component which is responsible for safecoins does not support smart contracts as we know them. It may in the future, but not the foreseeable future. One of the big decisions facing smart contracts is whether to make them turing complete, and if so, how to manage the incentive structure and costs around looping logic. All this is for the future, but the underlying safe network seems incredibly strong, and that strength starts with structured data.

It’s also possible that other structured data tokens besides safecoin may implement smart contracts, we can only know once the network is live and apps are being developed using the network.

Due to the efficiency of the safe network and the design around proof-of-resource instead of proof-of-work or proof-of-stake, it seems quite natural that smart contracts will live on this network, incentivising the consumption of computation resource along side the current design of storage and bandwidth resource.

There may be other ways to implement smart contracts on the safe network other than utilizing safecoin. If you can think of any please add to the discussion using the link at the very bottom of all of this.

Needs to be updated to change Structured Data to Mutable Data, but otherwise it’s ok.

My view on smart contracts is they’re an ‘extension’ of multisig transactions (on both safe and blockchain).

A transaction (on both systems) is basically a tiny program, something like:

if (signature == valid && inputs == valid) {
    commit transaction
}

A multisig transaction increases the complexity of the conditions, and a smart contract increases it further again, potentially also adding complexity to the actions to take.

So really the idea of smart contracts is already possible on the safe network, the question is how far their capabilities can stretch.

Then there’s the issue of oracles and sources of truth external to the network data. This is the part which which makes smart contracts really interesting. But to me that’s outside the scope of either blockchains or the safe network.


#16

This question comes up alot in different ways. And a few answers:

In terms of “smart contracts” (or code that executes commands automatically when conditions are met) then yes, a SAFE Network that works as planned could remove the need for many blockchain projects that exist today (ETH, NEO, EOS etc) by being much faster, cheaper, anonymous and can be written in any code language (not just Solidity, etc).

In terms of currency (looking more at bitcoin) and the core, original blockchain ideologies, I could see SafeCoin and Bitcoin existing side by side, for different purposes (with SafeCoin being much bigger and more widely used, though). I have heard Mr Irvine talk about how bitcoin and it’s public ledger would be great for governments and public companies to use, so everyone can track their spending transparenly, while SafeCoin being best for all the regular people of the world, to give them freedom and privacy.

It will be interesting to see how everything plays out :slight_smile: and those are some big picture ideas to think about


#17

Exactly the clarification I was asking for.
Thank you


#18

No. That looks awesome. I will get stuck into it tomorrow. Thanks


#19

Thank you @dirvine for such a prompt input on the question!
Yes it gives some ideas.

So, for others the distributed computing might be some whole other thing than the smart contracts (and I absolutely see how so), but to me they would both (potentially) be capable of solving my biggest need when developing for SAFE net: where to run the objective decision taking parts of the backend code. I did read some about kSnarkz but my math is not at the level that it permits me to readily grasp it. And besides, it seems to not be at the doorstep.

So, that lead me into the thoughts about taking some sort of short cut to enabling “backend code” running. (I guess the very notion of backend needs to be reshaped a bit with regards to this. Client side code is still client side code. Traditional backend would be, distributed code? Distributed execution of… code? Distributed/client side might do, but Network Agreed Logic, that was a good one @dirvine . NAL.)

Anyway, this NAL (network agreed logic), implemented in the app layer, I was just very naïvely imagining it as perhaps:
(and bare with my very basic understanding of SAFE net, and the resulting misunderstandings of limitations, possibilities, and reasonable approaches)
A NAL-app (the agent that @Traktion talks of?) that runs on any client that chooses to run it, will tap into repositories of code that has been submitted by app builders. So it will have a directory of datamaps, where each datamap is keeping track of all the files pertinent to the source code of a specific app.

When a node has this NAL-app (agent) enabled, it opens up for seemingly random requests from other nodes’ NAL-apps, to take some input, and run it with some part of code, and return the result. Like, run: app x, file y, with input p.
So, when some code is supposed to run, any interface for letting a user interact with it, would communicate with the local NAL-app, (which would in effect constitute this ui’s “backend”), the local NAL-app would communicate with a chosen set of nodes on the network and request the execution of some code with some data input, and by consensus choose the agreed outcome of the operation. This would be fed into subsequent code execution or stored as state in the network.

And… here comes multisig that you mentioned @dirvine. Somewhere there it would be used.
So, I am thinking here of groups, xor distance etc. would determine which nodes would be responsible for running which code. But, a very popular app would need to partition the workload not based on code file but on something else, because it would bottleneck otherwise.

Am I thinking totally wrong about this? With poor understanding, ideas you come up with tend to be really clumsy and awkward, I know that by experience :smiley:


#20

You are right on track. So several chained mutable data items can be waiting on signatures from deterministic or non deterministic groups (network or apps) and coded clearly that way. Then these signatures add up along a graph and as they do they execute various methods as the MD makes the change the signatures allow.

So for instance ( a super simple naive example) , if we imagine MD items

A -> Receives info from a human or IOT/AI etc. -> Signs B
B -> Receives a defined number of this verifiable data from known nodes/groups -> Signs A
A -> transfers a safecoin to X whoever X may be.

The network change is quite simple and subtle, basically MD items need to hold signatures until they accumulate. This can be done quite nicely if each sig has a unique identifier (UUID) and allowed then signers to remove that signature based on further inputs.

I hope that helps with NAL :smiley: