A number of days in the past I had an concept. What if I might have my residence server robotically obtain my photograph library from iCloud and sync the adjustments to Sia utilizing the recently-released SiaSync software? And what if I might entry and browse these recordsdata on different gadgets, like my iPhone or iPad?
First, although, I would wish a approach to add and obtain Sia recordsdata from iOS. Though there’s a third-party cellular app accessible for Sia, it’s unique to Android and requires operating a full node on the gadget. Was there a greater method?
I contacted Nebulous core developer Luke Champine to search out out. Because it turned out, he too was fascinated with writing cellular apps for Sia utilizing his
us venture! We rapidly started placing collectively a easy app, with Luke dealing with the Sia-specific code and
us bindings, and myself dealing with the UI/UX. (We additionally collaborated on this weblog submit.) By the top of the weekend, we had been giddy with pleasure, as a result of we had succeeded in importing and downloading a file, speaking on to Sia hosts from an actual iPhone, with no full node. See for your self:
So, what’s occurring behind the scenes right here? What’s up with the QR code, and what’s a “Shard Server?” And why does it take so lengthy to add a tiny picture? Learn on to be taught the solutions. If you wish to bounce straight into the code, although, you will discover the GitHub repo for the app right here: https://github.com/DangerCZ/SiaUs-iOS
The way it Works
We start by scanning a QR code that comprises a Sia file contract. We don’t kind the contract on the gadget itself; a minimum of for now, we have to get our contracts from an exterior supply. Try the
us-bindings repository for particulars on tips on how to purchase a contract and convert it to a QR code.
The contract tells us the general public key of the host we’re speaking with, however not its IP handle. Hosts solely announce their IP handle on the Sia blockchain, and we don’t wish to retailer the entire blockchain on our cellphone. That is the place the
shard server comes into play. Very similar to a DNS server, this server watches the blockchain and gives a public lookup desk for host IP addresses. Anybody can run a
shard server; within the demo, we connect with Luke’s occasion.
Due to the brand new protocol launched in Sia v1.4.0, that is all the data we have to add and obtain! The cellular app makes use of the
us filesystem code, compiled for iOS utilizing
us handles all of the Sia-specific particulars, the cellular app developer can give attention to what they do greatest.
Lastly: why is the add gradual? It is because Sia has to add a minimum of Four MiB at a time, so we’ve to pad our photograph out to Four MiB earlier than importing. There are plans to enhance this limitation in later variations of the Sia protocol, however for now we’ve to work round it. For instance, we might wait till the consumer has “uploaded” Four MiB of images earlier than we really ship something to the host. Or we might add asynchronously, like many cloud storage apps do, to make the delay much less noticeable.
The demo app makes use of a single contract, which suggests our knowledge is on the mercy of a single host. An actual app ought to use many contracts and retailer its recordsdata redundantly. Moreover, since
us doesn’t robotically renew your contracts, the app developer is liable for this. Apps ought to show a warning notification when contracts are vulnerable to expiring.
Each of those points could possibly be solved by a contract administration service. Like
shard, this is able to be an exterior server (run by you or a 3rd get together) that handles forming and renewing Sia contracts. The cellular app might then obtain a set of contracts instantly from the server, eradicating the necessity for QR code scanning, and question the server recurrently to obtain renewed contracts. Maybe the app developer might even present contracts instantly by way of in-app purchases, giving the developer a income.
We’ve got proven that it’s attainable to jot down cellular apps that retailer and retrieve knowledge on the Sia community. Whereas our demo app was written for iOS, the
us bindings are appropriate with Android as properly. We hope that this demo conjures up different cellular builders to create apps which are far more refined than our easy proof-of-concept. 🙂
If you’re fascinated with creating a cellular app, get in contact with @Hazard#1924 or @nemo#4926 on the Sia Discord. The
us bindings are removed from full, so suggestions can be appreciated. Let’s construct one thing cool collectively!