Giter VIP home page Giter VIP logo

nolik-cli's Introduction

Nolik CLI

Nolik CLI is an app that allows sending data (key-value data, texts, images, video, pdfs etc.) directly between peers without a third party. It requires a local Substrate (with Nolik pallet) and IPFS nodes. Follow the installation instructions in the Nolik repository.

Application Setup

Download the CLI app

git clone https://github.com/chainify/nolik-cli

Config file

Config file stores users' wallets and accounts. It is automatically generated by the app and located at the address:

~/.nolik/config.toml

Wallet config:

  • alias - a short one-word name for a wallet
  • public - a public key of a wallet in AccountId32 format
  • seed - a seed phrase of a wallet. Please keep it safe, and do not share it with others!
  • bs58seed - wallet seed phrase in Base58 format. You can use it to import your wallet on other devices.

Account config:

  • alias - a short one-word name for a wallet
  • public - a public key of an account in Base 58 format. The Bs58 public key is an account's address to receive data from others.
  • seed - a seed phrase of an account. Please keep it safe, and do not share it with others!
  • bs68seed - account seed phrase in Base58 format. You can use it to import your account on other devices.

Index file

Index file stores your outgoing and incoming messages. It is automatically generated by the app and located at the address:

~/.nolik/index.toml

The better way of storing data would be a local database, but this is a proof of concept.

Message data:

  • index - the index of a message
  • public - the public key of your account (sender or recipient)
  • hash - an IPFS ID of the message
  • nonce - the unique secret nonce of a message
  • from - the sender of a message
  • to - message recipients
  • entries - saved entries, if any
  • files - links to saved files, if any

Using the app

To use the app, you will have to generate at least one Wallet and one Account.

Generate a new Wallet

The wallet is used to hold the tokens and pay for sending the messages.

cargo run -- add wallet --alias personal

Valid flags:

  • --alias - is a short one-word name for your wallet (Required, Unique)
  • --import - import the seed phrase (Base58 encryption) for your wallet (Required, Unique)

Generate a new account

Accounts are required for sending and receiving encrypted messages. Each account has a pair of a public and a private key. The public key (Base58 encryption) is an address of an account. You can create as many accounts as you want.

cargo run -- add account --alias alice

Valid flags:

  • --alias - is a short one-word name for your account (Required, Unique)
  • --import - import the seed phrase (Base58 encryption) for your wallet (Required, Unique)

Get coins

For demo purposes, you can get free coins from Alice's Keyring account.

cargo run -- get coins -w personal

Valid flags:

  • -w | --wallet - an alias or a public key (Base58 encryption) of your wallet (Required, Unique)

Adding an owner to an account

Each account has to have an owner (the wallet). That is required to make sure that the wallet has a right to broadcast the message on behalf of a particular account. One account can have multiple owners. You can find more info about account owners in a Nolik pallet description.

cargo run -- add owner -a alice -w personal

Valid flags:

  • -a | --account - the account alias or a public key (Base58 encryption) that needs a new owner (Required, Unique)
  • -w | --wallet - the wallet alias or a public key (Base58 encryption) that will be an owner (Required, Unique)

Composing the message

Before sending, the message should be composed first and then saved to the IPFS network. It is saved as a batch and contains the same message encrypted for each recipient.

cargo run -- compose message -s alice -r Gq5xd5c62w4fryJx8poYexoBJAy9JUpjir9vR4qMDF8z -k SUBJECT -v testing -k BODY -v hello_world -f /Users/admin/Desktop/video.mp4

Valid flags:

  • -s | --sender - the message's sender. The alias or a public key (Base58 encryption) for your account (Require, Unique)
  • -r | --recipient - the message recipient. A public key (Base58 encryption) of the recipient (Required, Non-Unique)
  • -k | --key - the message's key. This attribute requires a corresponding Value (Optional, Non-Unique)
  • -v | --value - the message's value. This attribute requires a corresponding Key (Optional, Non-Unique)
  • -f | --file - the absolute path to the file you want to send (Optional, Non-Unique)

In case of successful message composing, you will get an IPFS hash of the saved file (for instance, QmTFiymizv6yTBLbHTkWe7h4Giy9yg623rjMoMeQk29hf3). That hash is required to send the message. Just use command-V to paste it. The blockchain runtime checks the uniqueness of the message.

Send the message

To successfully send the message, the sender should not be on the Blacklist of a recipient. If the recipient has a Whitelist, the sender's address should be in it.

cargo run -- send message -w personal -h QmTFiymizv6yTBLbHTkWe7h4Giy9yg623rjMoMeQk29hf3

Valid keys:

  • -w | --wallet - the wallet alias or a public key (Base58 encryption) of an owner of a sender's address (Required, Unique)
  • -h | --hash - the IPFS hash of a saved composed file (Required, Unique)

Update the Blacklist

A Blacklist is a set of addresses without the right to send the message to the recipient's address. By default, the Blacklist of an account does not contain any addresses. At this point, there is only an option to add new senders' addresses. The address should be either on a Blacklist or a Whitelist

cargo run -- update blacklist --add QmTFiymizv6yTBLbHTkWe7h4Giy9yg623rjMoMeQk29hf3 --for alice -w personal

Valid keys:

  • --for - the alias or a public key (Base58 encryption) of an account that will update the Blacklist (Required, Unique)
  • --add - the public key (Base58 encryption) of a new address in the Blacklist (Required, Unique)
  • -w | --wallet - an alias or a public key (Base58 encryption) of the owner's wallet

Update the Whitelist

A Whitelist is a set of addresses with the right to send the message to the recipient's address. By default, the Whitelist of an account does not contain any addresses. At this point, there is only an option to add new senders' addresses. The address should be either on a Blacklist or a Whitelist

Valid keys:

  • --for - the alias or a public key (Base58 encryption) of an account that will update the Whitelist (Required, Unique)
  • --add - the public key (Base58 encryption) of a new address in the Whitelist (Required, Unique)
  • -w | --wallet - an alias or a public key (Base58 encryption) of the owner's wallet

Get the messages

Getting messages for your account. Please notice that you will get both outgoing and incoming messages.

cargo run -- get messages -a alice

Valid keys:

  • -a | --account - the alias or a public key (Base 58 encryption) of your account (Required, Unique)

The decrypted messages are saved to the ~/.nolik/index.toml file.

Testing

You must run a local blockchain and an IPFS node for testing.

  1. Go to your Nolik directory
  2. Stop running nodes if any

docker compose stop

  1. Launch the node in dev mode

docker compose -f docker-compose.dev.yml up -d

  1. Use Rust's native cargo command to run tests

cargo test -- --test-threads=1

nolik-cli's People

Contributors

amrbz 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.