Skip to content

Commit

Permalink
Merge pull request #30 from neo-project/dev
Browse files Browse the repository at this point in the history
master < dev
  • Loading branch information
apisit authored Apr 6, 2022
2 parents c6071e9 + 3991c8f commit 862d7a9
Show file tree
Hide file tree
Showing 29 changed files with 1,516 additions and 58 deletions.
36 changes: 34 additions & 2 deletions docs/n3/Advances/Neo VM instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,22 @@ Copy, remove and swap the elements of the stack.
| Fee | 0.00000008 GAS |
| Function | Returns the remainder after dividing a by b. |

#### POW

| Instruction | POW |
| ----------- | -------------------------------------------------- |
| Bytecode | 0xA3 |
| Fee | 0.00000064 GAS |
| Function | The result of raising value to the exponent power. |

#### SQRT

| Instruction | SQRT |
| ----------- | ---------------------------------------------- |
| Bytecode | 0xA4 |
| Fee | 0.00000064 GAS |
| Function | Returns the square root of a specified number. |

#### SHL

| Instruction | SHL |
Expand Down Expand Up @@ -903,20 +919,36 @@ Copy, remove and swap the elements of the stack.

It has implemented common operations for array, map, struct, etc.

#### PACKMAP

| Instruction | PACKMAP |
| ----------- | ------------------------------------------------------------ |
| Bytecode | 0xBE |
| Fee | 0.00002048 GAS |
| Function | A value n is taken from top of main stack. The next n*2 items on main stack are removed, put inside n-sized map and this map is put on top of the main stack. |

#### PACKSTRUCT

| Instruction | PACKSTRUCT |
| ----------- | ------------------------------------------------------------ |
| Bytecode | 0xBF |
| Fee | 0.00002048 GAS |
| Function | A value n is taken from top of main stack. The next n items on main stack are removed, put inside n-sized struct and this struct is put on top of the main stack. |

#### PACK

| Instruction | PACK |
|----------|-----------------------------------|
| Bytecode | 0xC0 |
| Fee | 0.00000512 GAS |
| Fee | 0.00002048 GAS |
| Function | A value n is taken from top of main stack. The next n items on main stack are removed, put inside n-sized array and this array is put on top of the main stack. |

#### UNPACK

| Instruction | UNPACK |
|----------|------------------------------------|
| Bytecode | 0xC1 |
| Fee | 0.00000512 GAS |
| Fee | 0.00002048 GAS |
| Function | An array is removed from top of the main stack. Its elements are put on top of the main stack (in reverse order) and the array size is also put on main stack. |

#### NEWARRAY0
Expand Down
2 changes: 1 addition & 1 deletion docs/n3/Advances/Oracles.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Oracle service currently supports two URL schemes, `https` and `neofs`. `https`

- **Fees**

Neo Oracle Service charges the user by the number of requests, 0.5 GAS for each. Besides, the user has to pay additional fees for the callback function. All the fees will be paid when the Request is created.
Neo Oracle Service charges the user by the number of requests, 0.5 GAS by default for each. Besides, the user has to pay additional fees for the callback function. All the fees will be paid when the Request is created.

- **Rewards**

Expand Down
12 changes: 6 additions & 6 deletions docs/n3/exchange/transaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,14 @@ The parameters related to a transaction in the file are the following:
"value": "uXtKzX+CD2HS1NT5rqXrUEmN31U="
}
```

- to account: The second object in the array is the account address where the asset is transferred to. Its type "bytearray" and the value "7ztGBn8vR7L38EQqojcghdCHCO8=“ can be decoded to "Nhiuh11SHF4n9FE6G5LuFHHYc7Lgws9U1z" with base64. If the address is an exchange account address, it is a deposit transaction.

```json
{
"type": "ByteString",
"type": "ByteString",
"value": "7ztGBn8vR7L38EQqojcghdCHCO8="
}
}
```

- amount: The last object in the array is the transfer amount, which value is 800000000000. Since the decimal is 8 bit the value is actually 8000.00000000.
Expand Down Expand Up @@ -439,10 +439,10 @@ This command verifies the wallet password.

##### Example

Transfer 100 Neo to the address AMwS5twG1LLJA4USMPFf5UugfUvEfNDz6e:
Transfer 100 Neo to the address NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag:

```
neo> send a1760976db5fcdfab2a9930e8f6ce875b2d18225 AMwS5twG1LLJA4USMPFf5UugfUvEfNDz6e 100
neo> send a1760976db5fcdfab2a9930e8f6ce875b2d18225 NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag 100
password: ********
TXID: 0x8f831d8de723093316c05749a053a226514bc06338b2bceb50db690610e0b92f
```
Expand All @@ -452,7 +452,7 @@ If you are not sure of the asset ID, you can enter `list asset` to view all asse
In above example, we can also replace the asset ID with asset abbreviation, as shown below:
```
neo> send gas AMwS5twG1LLJA4USMPFf5UugfUvEfNDz6e 100
neo> send gas NYxb4fSZVKAz8YsgaPK2WkT3KcAE9b3Vag 100
password: ********
TXID: 0xae0675797c2d738dcadb21cec3f1809ff453ac291046a05ac679cbd95b79c856
```
Expand Down
4 changes: 2 additions & 2 deletions docs/n3/foundation/Cryptography/encode_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Example:

| String Content | byte[] |
| --- | --- |
| <nobr>AXaXZjZGA3qhQRTCsyG5uFKr9HeShgVhTF</nobr> | [0x17, 0xad, 0x5c, 0xac, 0x59, 0x6a, 0x1e, 0xf6, 0xc1, 0x8a, 0xc1, 0x74, 0x6d, 0xfd, 0x30, 0x4f, 0x93, 0x96, 0x43, 0x54, 0xb5, 0x78, 0xa5, 0x83, 0x22] |
| NTRAJ9EEjHFHhHZvMKEKfkceg5V9ppx5ZP | [0x35, 0x52, 0x4e, 0x37, 0xb7, 0x01, 0x39, 0xc8, 0x96, 0xeb, 0xd5, 0x4a, 0x86, 0x48, 0xd3, 0xfa, 0x78, 0x6b, 0x26, 0x48, 0x76, 0xea, 0xc5, 0x26, 0xce] |

Scenarios:

Expand Down Expand Up @@ -93,7 +93,7 @@ Example:

| String content | byte[] |
| --- | --- |
| <nobr>AXaXZjZGA3qhQRTCsyG5uFKr9HeShgVhTF</nobr> | [0x17, 0xad, 0x5c, 0xac, 0x59, 0x6a, 0x1e, 0xf6, 0xc1, 0x8a, 0xc1, 0x74, 0x6d, 0xfd, 0x30, 0x4f, 0x93, 0x96, 0x43, 0x54, 0xb5] |
| NTRAJ9EEjHFHhHZvMKEKfkceg5V9ppx5ZP | [0x35, 0x52, 0x4e, 0x37, 0xb7, 0x01, 0x39, 0xc8, 0x96, 0xeb, 0xd5, 0x4a, 0x86, 0x48, 0xd3, 0xfa, 0x78, 0x6b, 0x26, 0x48, 0x76] |

Scenarios:

Expand Down
2 changes: 1 addition & 1 deletion docs/n3/foundation/Cryptography/hash_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Scenarios:

- db3、NEP6 wallet secret key storage, export & validation.

### Murmur3
### Murmur32

Murmur is kind of non-cryptographic hash algorithm and suits for general hash indexing. It is proposed by Austin Appleby in 2008. Later several derived versions are released. Compared with other popular hash functions, Murmur's random distribution performance is better for keys with high regularity.

Expand Down
2 changes: 1 addition & 1 deletion docs/n3/foundation/Transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ For better understanding, suppose there is a contract invocation chain: **[entry

And the Target contract invokes CheckWitness to verify the signature. The verification result varies when `scopes` is set to different value.

- `None` - The verification is passed no matter where the **Target** contract is.
- `None` - The verification is not passed no matter where the **Target** contract is.
- `Global` - The verification is passed no matter where the **Target** contract is.
- `CallByEntry` - The verification is passed only when the **Target** contract is **entry** or **Contract A**.
- `CustomContracts` - The verification is passed only when the **Target** contract belongs to **CustomContracts**, a contract list you need to customize.
Expand Down
5 changes: 5 additions & 0 deletions docs/n3/neofs/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"label": "NeoFS",
"position": 9
}

17 changes: 17 additions & 0 deletions docs/n3/neofs/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: 'Neo FS Go SDK Documentation'
description: "This section covers the elements of NeoFS and the NeoFS SDK written in Go"
author: ngdenterprise
tags: [ "NEOFS"]
skill: intermediate
sidebar: true
---
## Neo Community Documentation

Please join us on the Neo discord server if you would like any support and please contribute back if you have something to add!

With time there will be an easy to use 'get things done' API for Go, and a starter app for Javascript developers to build on top of.

:::note
Best place to get started is probably in the [overview](/neo-docs/introduction/overview) area, or if you want to get cracking, head over the [creating a wallet!](/neo-docs/tutorials/wallets)
:::
44 changes: 44 additions & 0 deletions docs/n3/neofs/introduction/Concepts.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "Concepts"
date: 2022-01-18T21:13:48Z
---

NeoFS is very carefully designed to offer the power of a filesytem with all the expected capabilities, on top of a decentralised network.

This means that files/folders etc can have permissions to who can read/write to them who can delete etc etc.

As NeoFS is built on top of the Neo blockchain, these permissions are based on wallet addresses of users.

### Objects

[Objects](/docs/n3/neofs/topics/objects) represent all files/data that is stored on NeoFS. Objects are accessed via SessionTokens or Bearer Tokens

### Containers

A [container](/docs/n3/neofs/topics/containers) controls the basic permissions that are applied to all content within it. Think of a container like a drive on a computer or network (and not a folder per se).

All objects must live within a container, their permissions will default to the permissions of the container

### OwnerID

OwnerID is derived from the public or private key of a wallet and is unique to that wallet.

### Policies

Container policies define the way objects will be placed among storage nodes. That is, you as the container owner can decide what type of node should store a file for you.

### EACL

Containers and sessions/bearer tokens can have differeing permissions. By default permissions will be the same as the container's however if permissions are attached as a table to the container, or a bearer token is sent as part of a request, then they can override the permissions of the container

Read more about [ACL here](https://github.com/nspcc-dev/neofs-spec/blob/master/01-arch/07-acl.md)

### Access

Access is made using session tokens (derived from the private key), or bearer tokens, which are distributed by the container owner to others they want to be able to offer restricted capabilities (and time limits) to other users

### Wallets

A wallet is specifically an item that takes the NEP-6 format and contains any number of accounts. Accounts contain a public address, a private key and other information (read more here)

Wallets contain accounts. The first account in a wallet is the default and its wallet Address is the default address
48 changes: 48 additions & 0 deletions docs/n3/neofs/introduction/Libraries.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: "Libraries"
date: 2022-01-18T21:13:48Z
---

The Go SDK is the basis of all the functionality that is available to you as a developer with regards to NeoFS.

the Neo-Go package offers all the functionalities that you will require to interact with the Neo blockchain and wallets

## SDK

The SDK is responsible for providing functionality to interact with NeoFS itself via gRPC requests. You will need the SDK for such things as:

* creating, retrieving, deleting containers
* creating, updating, retrieving, deleting objects
* creating basic and extended ACL rules for containers

##### [find it here](https://github.com/nspcc-dev/neofs-sdk-go)

## Neo-Go library

General interaction with NeoFS doesn't require Neo-Go however invariably you will need to manage wallets or use cryptographic functions that are required while setting permissions throughout the NeoFS system.

##### [find it here](https://github.com/nspcc-dev/neo-go)

### Helpers

Sometimes there will be throughout the tutorials the need to reuse functions from elsewhere. These are stored in the Helpers tutorial and will be useful functions to have available within your projects

:::note
See Helpers, whenever you see `helper.` in a code sample
:::

### Neo FS local environment

You can clone the repository so that you can start NeoFS locally, this may be beneficial for education reasons or perhaps to run integration tests against a local NeoFS

https://github.com/nspcc-dev/neofs-dev-env/

### Resources

- Javascript interaction with NeoFS - https://github.com/CityOfZion/neofs-demo/blob/461466ab5450f4defa75c12e81a095b2b1411e0d/src/neofs.js#L167
- Smart contract interaction in Go - https://github.com/nspcc-dev/neo-go/blob/f9e8dcbed8c9325983403f25a1a37e764523ff62/cli/smartcontract/smart_contract.go#L574
- Transaction documentation in Go - https://pkg.go.dev/github.com/nspcc-dev/[email protected]/pkg/core/transaction
- neo-go low level docs - https://github.com/nspcc-dev/neo-go/tree/master/docs
- gRPC neofs docs - https://github.com/nspcc-dev/neofs-api/tree/master/proto-docs
- storage/placement policy low level docs - https://github.com/nspcc-dev/neofs-spec/blob/master/01-arch/02-policy.md
- ACL low level docs - https://github.com/nspcc-dev/neofs-spec/blob/master/01-arch/07-acl.md
44 changes: 44 additions & 0 deletions docs/n3/neofs/introduction/Overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "Overview"
date: 2022-01-18T21:13:48Z
---

This chapter outlines the [concepts](/docs/n3/neofs/introduction/concepts) and top level points required to understand and enjoy building on neo & NeoFS

### Starting out

The topics here are primarily in Go, however where we have code snippets for other languages we will endeavour to add them.

You will need:

1. Go language installed and running
2. [NeoFS SDK - Go](https://github.com/nspcc-dev/neofs-sdk-go)
3. [Neo Go library](https://github.com/nspcc-dev/neo-go)
4. Read the [wallets](/docs/n3/neofs/topics/wallets/) page as it will outline the basis of working with Neo and NeoFS - a wallet.
5. Neo/Gas in your wallet. You can get these from the [testnet faucet here](https://neowish.ngd.network/#/)
6. These libraries will assume you are using the testnet throughout. All urls referenced can be retrieved from NeoFS or from Dora the explorer.

These tutorials are primarily in Go, however where we have code snippets for other languages we will endeavour to add them.

:::note
This documentation is not a tutorial, it is a reference to using the SDK, however in general when writing an application you will require:
:::

1. a private key
2. with this, you can instantiate a wallet and an account held by the wallet.
3. the wallet allows you to instantiate a NeoFS client.
4. Once you have a client, you can interact with NeoFS
5. To do so however, you will need a session token (or a bearer token but start with a session token). The session token contains a signature that validates your wallet against NeoFS.
6. You might create a container, put an object in a container, or delete an object.

### Libraries

[Libraries](/docs/n3/neofs/introduction/libraries) covers the packages and libraries that are required to interact with Neo and NeoFS in Go

### References

* [neofs-spec](https://nspcc.ru/upload/neofs-spec-latest.pdf#13)

### With Thanks To

* [NSPCC team](https://github.com/nspcc-dev/) - team behind NeoFS, the [neo-go-sdk](https://github.com/nspcc-dev/neofs-sdk-go) and the [neo-go](github.com/nspcc-dev/neo-go) packages
4 changes: 4 additions & 0 deletions docs/n3/neofs/introduction/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "NeoFS Overview",
"position": 1
}
4 changes: 4 additions & 0 deletions docs/n3/neofs/topics/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "NeoFS Capabilities",
"position": 2
}
Loading

0 comments on commit 862d7a9

Please sign in to comment.