0.0.16 • Published 4 years ago

stardust-binary v0.0.16

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

Stardust Binary

Source Code for the Stardust API program

Basic Bash Examples

# Hash a value
stardust hash --type='string' --value='Hello'

# You can use the hashed value from above and sign it with your private key.
stardust sign --hash='0xcec38027c6953ccda44f5b57cf4fda4925c96672df03eb5b853c4e49d07526fd' --privKey='0x648e00628344e7d436fa7c13ab6ff890c0019eb0f0b158b6107160084ee7eb29'

# Sign POST data with your private key
stardust signData --path='game.deploy' --data='{"name":"GameName","symbol":"GAME","desc":"Game Desc","image":"image.png","rarityNames":["Common","Rare","Super Rare","Limited Edition","Unique"],"rarityPercs":[8000,1500,400,85,15],"from":"0xcfCcdb82E097411A459FbB0d2635E20411CDf588"}' --privKey='0x648e00628344e7d436fa7c13ab6ff890c0019eb0f0b158b6107160084ee7eb29'

# Use the signed data from above to make a POST request. Returns a `txId` which can then be used to query the transaction state.
stardust POST --path='game.deploy' --data='{"name":"GameName","symbol":"GAME","desc":"Game Desc","image":"image.png","rarityNames":["Common","Rare","Super Rare","Limited Edition","Unique"],"rarityPercs":[8000,1500,400,85,15],"from":"0xcfCcdb82E097411A459FbB0d2635E20411CDf588","timestamp":1563799550356,"signedMessage":"0x67ca59c61f86c9221e1ddd70e3f883b93097c82e1f8602d9998b49fdf72a976d161f9668d10aa0120d77569f23c184660e7a7bed800fbaefbb9c3bca054a3dbf1ccfb70bbab098668c104bdcd8236aa9aa84da281ec28365bc5f799811d149c662"}'

# Use the `txId` returned from the above command to query the transaction state and data.
stardust tx --txId='383848731581'

# Use the `gameAddr` returned from the above command to request the game data.
stardust GET --path='game.game' --gameAddr='0x00068d67CE001dC37103b06A75Ff06160e95a4C5'

Implementation Helpers

Take from bash section, plug into this:

TypeScript

import {exec} from 'shelljs';

const runCmd = (cmd: string) => exec(cmd, {silent: true}).stdout.replace('\n', '');

Python

import subprocess

def runCmd(cmd): return subprocess.run(cmd, shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')

C++

#include <iostream>

using namespace std;

string runCmd(const char* cmd) {
    char buffer[128];
    string result;
    FILE* pipe = popen(cmd, "r");

    while (fgets(buffer, sizeof buffer, pipe) != NULL) { result += buffer; }

    pclose(pipe);
    return result;
}

Java

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Stardust {
    public static void main(String[] args) {}

    public static String runCmd(String cmd) {
        StringBuffer output = new StringBuffer();

        try {
            Process p = Runtime.getRuntime().exec(cmd);
            p.waitFor();

            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

            String line;
            while ((line = reader.readLine()) != null) {
                output.append(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return output.toString();
    }
}
0.0.16

4 years ago

0.0.14

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago