SaseulJS
SaseulJS is a toolkit for developing decentralized applications based on the SASEUL blockchain engine. You can use this toolkit to create and send transactions and requests to the SASEUL network. You can also create and register smart contracts that operate on the SASEUL network.
If you need information about SASEUL, you can refer to the link below.
- SASEUL Website: https://saseul.com
- Guardee Wallet: https://applink.guardee.io/
- Block Explorer: https://explorer.saseul.com/
If you want to install the SASEUL engine, you can refer to the link below.
Dependencies
Installation
You can install saseul-js via a package manager:
NPM:
1
$ npm install saseul
…or you can also use it as follows.
Browser:
1
<script type="text/javascript" src="saseul.min.js"></script>
Quick Start
NPM:
1
$ npm install saseul
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const SASEUL = require('saseul');
SASEUL.Rpc.endpoint('<YOUR NODE ENDPOINT>'); // ex) blanc.saseul.net
// Create a wallet address.
let private_key = SASEUL.Sign.privateKey();
let public_key = SASEUL.Sign.publicKey('cd654a234b59a64c20781243d161f8b40b9e87d4ea2be1904e66497e22ccefa9');
let address = SASEUL.Sign.address('107acd459a0522abc4bab6719e30622bd9e08a9a54cd75dd76ce3f5f9dae846d');
// Create a balance inquiry request and check the result.
let get_balance = SASEUL.Rpc.signedRequest({"type":"GetBalance","address":address}, private_key);
SASEUL.Rpc.request(get_balance).then(function (r) { console.dir(r); });
// Create a transaction for sending SL and broadcast it.
let send = SASEUL.Rpc.signedTransaction({"type":"Send","to":"<address>","amount":"<amount>"}, private_key);
SASEUL.Rpc.broadcastTransaction(send).then(function (r) { console.dir(r); });
Browser:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
...
<div id="contents"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/tweetnacl/1.0.2/nacl.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/axios/1.3.5/axios.min.js"></script>
<script type="text/javascript" src="saseul.min.js"></script>
<script type="text/javascript">
let contents = document.getElementById('contents');
SASEUL.Rpc.endpoint('<YOUR NODE ENDPOINT>'); // ex) blanc.saseul.net
// Create a wallet address.
let private_key = SASEUL.Sign.privateKey();
let public_key = SASEUL.Sign.publicKey('cd654a234b59a64c20781243d161f8b40b9e87d4ea2be1904e66497e22ccefa9');
let address = SASEUL.Sign.address('107acd459a0522abc4bab6719e30622bd9e08a9a54cd75dd76ce3f5f9dae846d');
contents.innerHTML+= "<div>Private Key: " + private_key + "</div>";
contents.innerHTML+= "<div>Public Key: " + public_key + "</div>";
contents.innerHTML+= "<div>Address: " + address + "</div>";
// Create a balance inquiry request and check the result.
let get_balance = SASEUL.Rpc.signedRequest({"type":"GetBalance","address":address}, private_key);
SASEUL.Rpc.request(get_balance)
.then(function (r) { contents.innerHTML+= "<div>Get Balance: " + JSON.stringify(r, null, 2) + "</div>"; })
.catch(function (e) { contents.innerHTML+= "<div>Get Balance: " + JSON.stringify(e, null, 2) + "</div>"; });
// Create a transaction for sending SL and broadcast it.
let send = SASEUL.Rpc.signedTransaction({"type":"Send","to":"<address>","amount":"<amount>"}, private_key);
SASEUL.Rpc.broadcastTransaction(send)
.then(function (r) { contents.innerHTML+= "<div>Get Balance: " + JSON.stringify(r, null, 2) + "</div>"; })
.catch(function (e) { contents.innerHTML+= "<div>Send: " + JSON.stringify(e, null, 2) + "</div>"; });
</script>
...