NeoFS N3 TestNet Release and First Episode of NeoFS Beginner’s Guide

Introduction

NeoFS is a distributed, decentralized object storage platform developed by Neo SPCC.

NeoFS Components

NeoFS is a part of Neo network. It is managed by Neo Governance procedures and integrated through smart contracts and oracles.

First steps in NeoFS

Create Wallet

Let’s start with NeoFS СLI description and how to take the first steps.
First of all, you need to create a wallet and request N3 Testnet GAS tokens.

wget https://github.com/nspcc-dev/neo-go/releases/download/v0.94.0/neo-go-linux-amd64 -O neo-gochmod +x ./neo-go --version
neo-go wallet init -w new_wallet.json -a
neo-go wallet dump -w new_wallet.jsonneo-go wallet export -w new_wallet.json --decrypt {ADDRESS}
  1. Check your address here to see that everything is done correctly

Make a Deposit

To make a deposit to the NeoFS account, execute the transfer method to the NeoFS Smart Contract address.

neo-go wallet nep17 transfer -w {wallet} -r {NEO_ENDPOINT} --from {address} --to {NEOFS_CONTRACT_ADDRESS} --token GAS --amount {amount} hash160:{address}
  • {address} — N3 address
  • {NEO_ENDPOINT} — any N3 node (e.g., https://rpc1.n3.nspcc.ru:20331)
  • {NEOFS_CONTRACT_ADDRESS} — NeoFS contract address is NadZ8YfvkddivcFFkztZgfwxZyKf1acpRF in the current N3 Testnet version
  • {amount} — number of gas tokens to add to the NeoFS balance

Check NeoFS balance

To work with NeoFS, install NeoFS CLI.
Get it binary from the latest release here.

wget https://github.com/nspcc-dev/neofs-node/releases/download/v0.18.0/neofs-cli-linux-amd64.tar.gz -O neofs-cli.tar.gztar -xf neofs-cli.tar.gzchmod +x neofs-cli
neofs-cli -r {NEOFS_ENDPOINT} -k {WIF} accounting balance
  • {WIF} — private key in hex, WIF, or file path to .key file

Create your first container

In NeoFS, users put their data into Containers. Containers are like folders in a file system or buckets in Amazon’s S3 but with Storage Policy attached. Storage Policy is set up by the user and defines how objects in this container should be stored.

neofs-cli -r {NEOFS_ENDPOINT} -k {WIF} container create --policy "REP 3" --basic-acl public-read --await

Upload a cat to NeoFS

Let’s get a cute cat picture: cat.png. To put the object in our container, we should execute the neofs-cli command. We can also add some user headers to the object to run search operations by specific filters in the future. We want to set img_type as cat and my_attr as cute.

neofs-cli -r {NEOFS_ENDPOINT} -k {WIF} object put --file {FILE_PATH} --cid {CONTAINER_ID}

Get your cat or share it with friends

To get the object, you can use the command with either any key (in case of public container) or an owner key (in case of private container):

neofs-cli {NEOFS_ENDPOINT} -k {WIF} object get --cid {CONTAINER_ID} --oid {OBJECT_ID} --file {PATH_TO_FILE}

Search for objects with some specific attributes in the container

To run search operation you can use different filters by meta information of the objects. For example, you can filter objects by attributes declared in the previous steps:

Conclusion

Today, you have taken your first steps in NeoFS and tried the simplest object operations. Our next articles will cover how to use Storage Policies, set complex ACLs and exceptions for them, how to work with S3 gates, and more. Be with us and enjoy your storage experience.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store