Coder Social home page Coder Social logo

0g-storage-client's Introduction

0G Storage Client

Go implementation for client to interact with storage nodes in 0G Storage network.

SDK

Following packages can help applications to integrate with 0g storage network:

transfer : defines data structures and functions for transferring data between local and 0g storage. [kv]: defines structures to interact with 0g storage kv. [indexer]: select storage nodes to upload data from indexer which maintains trusted node list. [node]: defines RPC client structures to facilitate RPC interactions with 0g storage nodes and 0g key-value (KV) nodes.

CLI

Run go build under the root folder to compile the executable binary.

Global options

      --gas-limit uint     Custom gas limit to send transaction
      --gas-price uint     Custom gas price to send transaction
  -h, --help               help for 0g-storage-client
      --log-force-color    Force to output colorful logs
      --log-level string   Log level (default "info")

Generate test file

To generate a file for test purpose, especially with a fixed file size or random file size (without --size option):

./0g-storage-client gen --size <file_size_in_bytes>

Upload file

Use storage nodes urls directly:

./0g-storage-client upload --url <blockchain_rpc_endpoint> --contract <0g-storage_contract_address> --key <private_key> --node <storage_node_rpc_endpoint> --file <file_path>

The --node accept comma separated URLs, the client will submit the data segments to all these nodes according to their shard configurations.

Use indexer url to fetch storage nodes:

./0g-storage-client upload --url <blockchain_rpc_endpoint> --contract <0g-storage_contract_address> --key <private_key> --indexer <indexer_rpc_endpoint> --file <file_path>

Download file

./0g-storage-client download --node <storage_node_rpc_endpoint> --root <file_root_hash> --file <output_file_path>

To download file from multiple storage nodes in parallel, --node option supports to specify multiple comma separated URLs, e.g. url1,url2,url3.

If you want to verify the merkle proof of downloaded segment, please specify --proof option.

Write to KV

By storage node urls:

./0g-storage-client kv-write --url <blockchain_rpc_endpoint> --contract <0g-storage_contract_address> --key <private_key> --node <storage_node_rpc_endpoint> --stream-id <stream_id> --stream-keys <stream_keys> --stream-values <stream_values>

By indexer:

./0g-storage-client kv-write --url <blockchain_rpc_endpoint> --contract <0g-storage_contract_address> --key <private_key> --indexer <indexer_rpc_endpoint> --stream-id <stream_id> --stream-keys <stream_keys> --stream-values <stream_values>

--stream-keys and --stream-values are comma separated string list and their length must be equal.

Read from KV

./0g-storage-client kv-read --node <kv_node_rpc_endpoint> --stream-id <stream_id> --stream-keys <stream_keys>

Please pay attention here --node is the url of a KV node, different from the command above.

0g-storage-client's People

Contributors

minifrenchbread avatar boqiu avatar sparkmiw avatar 0g-peterzhb avatar zeroxsatoshi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.