Community-created, unofficial PHP SDK for the Skynet Decentralized Internet Network. siasky.net

Overview

Skynet PHP SDK

This SDK is a community-created, unofficial SDK in PHP for the Skynet Decentralized Internet Network. It is taken as primarily a port from https://github.com/SkynetLabs/skynet-js.

Better documentation will come in the future. However, despite being a mirror, there are some details to know to use the library. The API will also likely improve and change in the future. This initial version is a reflection of the JS library.

Classes

  • Skynet
    • This is the bottom layer of the system where most operations happen at
  • Registry
    • This is the basic key -> value store system. This is the database system that is used with your keypair to manage records
  • Db
    • This is the system that is used to set basic registry entries linked to your keypair, which are not encrypted
  • MySky
    • This is where all file management actions revolving around your account (seed) happen, including encrypted files. This also enables creating file paths that are stored as hashes in the Db and can also be encrypted via libsodium.

Functions

Most functions from skynet-js have been ported over. The ones of most interest will be in src/functions/mysky.php. Not all functions are grouped together the same way.

  • generateSeedPhrase
  • validatePhrase

Please note there are two versions of genKeyPairFromSeed in different namespaces since the mysky library uses a different version only for signing registry entries and getting your PUBLIC ID. \Skynet\functions\mysky\genKeyPairFromSeed uses an extra derivation hashing step for security.

It was decided given the evolution of PHP; these functions don't need to emulate PHP classes. So they are standalone functions that are inner dependant unless there is a reason to refactor.

Usage

You will most often want to make use of the MySky class. Example:

DO NOT USE THIS SEED. It is valid for demonstration purposes, but as it is published here, it can never be trusted since ANYONE can make use or abuse it. Portal can be configured but will default to siasky.net

Upload File

This example will upload a file and, by being logged in, will be pinned to your account:

$drive = new \Skynet\MySky('roster donuts tycoon dunes muffin vector nasty jingle goblet amidst often wife digit earth eight');
$drive->setPortalLogin('[email protected]', 'password');
$drive->setPortal('https://yourprivateportal.com');
$skyfile = $drive->getSkynet()->uploadFile(\Skynet\Types\File::fromResource('/mnt/data/file_to_upload.txt'));
echo $skyfile->getSkylink();

You can send raw data as well as long as it doesn't match a file:

$skyfile = $drive->getSkynet()->uploadFile(\Skynet\Types\File::fromResource('Hello World'));

Pin Skylink

This will pin a skylink to your account. A skylink must be pinned by atleast one portal to stay online. The skylink is a content ID including metadata:

$skynet = new \Skynet\Skynet();
$drive->setPortalLogin('[email protected]', 'password');
$skyfile = $drive->pinSkylink('XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg')
echo $skyfile->getSkylink();

Create Plaintext DataLink/Resolver

$drive = new \Skynet\MySky('roster donuts tycoon dunes muffin vector nasty jingle goblet amidst often wife digit earth eight');  
$drive->setPortalLogin('[email protected]', 'password');  
$drive->getDb()->setDataLink($drive->getKey()->getPrivatekey(), 'hello_world', 'XABvi7JtJbQSMAcDwnUnmp2FKDPjg8_tTTFP4BwMSxVdEg');  
$entry = $drive->getDb()->getRegistry()->getEntry( $drive->getKey()->getPublicKey(), 'hello_world');

Create JSON file

JSON data can be either a stdClass object or an array. the returned datalink is the skylink. It can be referenced again from the file path.

$drive = new \Skynet\MySky('roster donuts tycoon dunes muffin vector nasty jingle goblet amidst often wife digit earth eight');  
$drive->setPortalLogin('[email protected]', 'password');
$skylink = $drive->setJSON('/data/my_json_file.json', ['message' => 'hello world'] );
echo $skylink->getDataLink();

Contributing

Any contributions are welcome. I will rapidly be iterating on this software since running as a server-side language can be very different from the browser. Semver will be followed as practical. Consider this software tested because it has nearly all unit tests from the JS version, but still experimental as it has not gotten any real-world use yet, but that will change.

You might also like...
An open source Minecraft server (true-og.net)

true-og An open source Minecraft server (true-og.net) Website forked from aviel900 https://www.spigotmc.org/resources/minecraft-one-page-template.5973

A Slack integration to post GIF replies from replygif.net
A Slack integration to post GIF replies from replygif.net

Archibald Archibald is a Slack integration written in PHP to post tag-selected GIF replies from replygif.net into your current Slack channel or Direct

This is Laravel Framework. Referral User Management System, Payment using Coinpayment.net. etc

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Plugin de Wordpress para criar um Hacker News-like para o ManualdoUsuario.net

🪐 Órbita Plugin de Wordpress para criar um painel de debates baseado em links, similar ao Hacker News, para o Manual do Usuário. Rodar o projeto Requ

Patches that prevent malicious Minecraft plugins from saturating host internet resources for DDoS.
Patches that prevent malicious Minecraft plugins from saturating host internet resources for DDoS.

Minecraft Host DoS Botnet Patches Patches that prevent malicious Minecraft plugins from saturating host internet resources for DDoS. In recent events,

Uses internet-connectable temperature sensors to provide cooling/heating assist for small buildings, as well as weather data

ambient-hvac Uses internet-connectable temperature sensors to provide cooling/heating assist for houses and other small buildings, as well as weather

İnternet Vergi Dairesi Sorgualamaları

🧾 İnternet Vergi Dairesi Sorgulamaları Bu kütüphane, PHP aracılığıyla İnteraktif Vergi Dairesi Üzerinden Earsiv Fatura Sorgulama, Borç Sorgualama işl

Neural Network in pure PHP
Neural Network in pure PHP

rn Neural Network in pure PHP - ML Machine Learning - AI Artificial Intelligence RED NEURONAL WHAT DO THIS LIBRARY IN PURE PHP OF ARTIFICIAL INTELLIGE

A library for create network applications with PHP.
A library for create network applications with PHP.

SocketServer A library for create network applications with PHP. Installation. $ composer require thenlabs/socket-server Usage. The below code show a

Owner
Derrick Hammer
Derrick Hammer
Spotweb is a decentralized usenet community based on the Spotnet protocol.

Spotweb is a decentralized usenet community based on the Spotnet protocol. Spotweb requires an operational webserver with PHP5.6 installed, it

Spotweb 433 Jan 1, 2023
Spotweb is a decentralized usenet community based on the Spotnet protocol.

Spotweb Spotweb is a decentralized usenet community based on the Spotnet protocol. Spotweb requires an operational webserver with PHP5.6 installed, it

[sCRiPTz-TEAM] 2 Nov 29, 2021
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Minibase 16 Jun 7, 2022
A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Minibase 16 Jun 7, 2022
Raspberry Pi wifi hotspot with an offline-first community portal. Optionally shares internet access over Tor.

Raspberry Pi wifi hotspot with an offline-first community portal. Optionally shares internet access over Tor.

Martti Malmi 17 Dec 15, 2022
An unofficial PHP SDK for Deepgram's API.

An unofficial PHP SDK for Deepgram's audio transcription API. Getting Started Grab src/deepgram.php and include it in your project. Then: $deepgram =

Christopher Finke 1 May 3, 2022
A decentralized B2B NFT Marketplace for Cars

dCars dCars is a a B2B NFT Marketplae for Cars. Each car is treated as an NFT. On buying of the car, the ownership will be transferred to the buyer. T

Adnan Siddiqi 48 Dec 2, 2022
A customizable decentralized micro-blog (Twitter) and cms (Wordpress) that only you host and moderate.

Consider this --> each Miter account is individually hosted on a user's personal and private third party server (host) - either purchased or free - as

Vije Miller 3 Jun 8, 2022
An unofficial EdgeDB PHP client.

Unofficial EdgeDB HTTP PHP client Requirements PHP >= 8.0 (with fileinfo and mbstring) An EdgeDB server instance (tested with 1.0+9ecadfc) Quickstart

T3d 7 Aug 18, 2022
Unofficial Nest Learning Thermostat API

This is a PHP class that will allow you to monitor and control your Nest Learning Thermostat, and Nest Protect.

Guillaume Boudreau 297 Oct 28, 2022