Skip to content

Commit 799c76a

Browse files
committed
resources: Added polaris binary.
1 parent 3754453 commit 799c76a

File tree

6 files changed

+72
-18
lines changed

6 files changed

+72
-18
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*:
2+
# The API
3+
4+
Interacting with Polaris via Polaris-Swift is easy! Simply initialize a new API instance with a providing URI.
5+
In this case, I'm initializing a new API instance with the URI for my Raspberry Pi's Go-Polaris RPC API.
6+
*/
7+
8+
import Foundation
9+
import AppKit
10+
import PlaygroundSupport
11+
12+
let api = API(apiURI: "https://108.41.124.60:8000") // Initialize API instance
13+
14+
/*:
15+
## The Accounts API
16+
17+
When an API instance is created, so are instances of each package API. To access the accounts API, use api.Accounts.
18+
19+
### Creating a New Account
20+
21+
Like a few other methods in the Accounts API, NewAccount() does not take any parameters. Simply call api.Accounts.NewAccount() to generate a new ECDSA private key and public key, as well as a Polaris address (derived from the Sha3 hash of the public key). Like every other API method, NewAccount() will return a JSON dict representing the response from the node, and an error (if applicable).
22+
*/
23+
24+
let newAccountResponse = api.Accounts.NewAccount() // Initialize new account
25+
26+
let newAccountAddress = newAccountResponse.0!["message"] as! String // Your new account address!
27+
28+
print("Created new account successfully! Here's your address: \(newAccountAddress)") // Log new account
29+
30+
/*:
31+
* Callout(Forgot Your Address?):
32+
Use api.Accounts.GetAllAccounts() to get a list of all the accounts created on the local node.
33+
*/
34+
35+
let baseView = NSView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) // Placeholder to present address
36+
37+
PlaygroundPage.current.liveView = baseView // Set live view
38+
PlaygroundPage.current.needsIndefiniteExecution = true // Keep open
39+
40+
//: [Next](@next)

swift-polaris-playground.playground/Pages/Test.xcplaygroundpage/Contents.swift

Lines changed: 0 additions & 10 deletions
This file was deleted.

swift-polaris-playground.playground/Pages/Welcome.xcplaygroundpage/Contents.swift

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
/*:
2+
# Swift-Polaris
23

4+
## An Introduction
5+
6+
I love software. I mean, I love computers in general, but software in particular is what really interests me. But, at the moment, I've noticed something fundamentally limiting about how computing works today: centralization.
7+
This issue was first addressed by Satoshi Nakamoto through the creation of the Bitcoin network--a first-of-its-kind peer-to-peer digital currency. However, the Bitcoin network didn't really solve this issue of computing centralization. Another p2p currency known as Ethereum was created several years later that attempted to solve this issue. Unlike Bitcoin, Ethereum focused on distributed computations, rather than just monetary transfer. Ever since, Ethereum has reigned as the uncontested champion of distributed computing. However, in this peer-to-peer architecture that requires strict all-inclusive consensus, the network has become limited in throughput to some of its weakest nodes.
8+
9+
## A Proposition
10+
11+
Again, as time went by and these networks grew, both of them were eventually plauged with scalability, privacy, and throughput woes. In response, I propose a solution: Polaris.
12+
Polaris is a sharded, tangle-based digital currency and computations protocol. Unlike Ethereum and Bitcoin, Polaris can scale infinitely, as its consensus mechanism does not rely on the publishing of a transaction in a block, but rather the random sampling of network peers to publish the transaction. Additionally, as Polaris does not use proof-of-work as its consensus mechanism, transactions on the network do not require fees. As such, the network can be used as both a decentralized applications platform, and a data aggregation platform (e.g. IoT, data storage and hosting).
13+
14+
### Consensus
15+
16+
Although Polaris doesn't necessarily rely on proof-of-work per say, it still needs a way to reach consensus. How is this accomplished, one might ask? Simply put, the network is randomly sampled for a volunteering peer wishing to "vouch" for a transaction. After "vouching" for a transaction, a peer is then permitted to attach one of their own transactions to the parent transaction. As such, only transactions that have been "witnessed" by another peer can be considered valid.
17+
18+
## Implementation
19+
20+
So far, I've only implemented Polaris in Go. However, [Go-Polaris](https://github.com/polaris-project/go-polaris) has been written in such a way that different languages like swift can communicate with a node without having to run a real implementation in the language.
21+
22+
## A Quick Note
23+
24+
This Playground will need an internet connection, as it needs to connect to the Go-Polaris RPC JSON API. If one wishes to operate without an internet connection, replace each API(URI) call with API("https://127.0.0.1:8000"). Although, in order to connect to a locally running node API, one should also run an instance of Go-Polaris locally (i.e. `go install go-polaris` or `curl https://github.com/polaris-project/go-polaris/releases/download/v0.1.0/polaris-darwin
25+
26+
## Getting Started
27+
28+
To create your first account on the Polaris network, see [Hello, World](Hello,%20World).
329
*/
4-
5-
import Foundation
6-
7-
var str = "Hello, playground"
8-
9-
//: [Next](@next)
18.1 MB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mkdir data && mkdir data/config # Make data dir, config dir
2+
echo '{"alloc":{"e3891ace0bce06b4acaddcbe47afecdbdcae1fb6": 10}, "identifier": "main_net", "network": 0}' > data/config/config_main_net.json # Create Polaris monetary supply config
3+
chmod +x ./polaris # Allow run
4+
./polaris --network main_net --bootstrap-address localhost # Run polaris without an internet connection!
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<playground version='6.0' target-platform='macos'>
2+
<playground version='6.0' target-platform='macos' display-mode='raw'>
33
<pages>
4-
<page name='Test'/>
54
<page name='Welcome'/>
5+
<page name='Hello, World'/>
66
</pages>
77
</playground>

0 commit comments

Comments
 (0)