基于区块链的毕业设计ethoFS SDK – ethoFS软件开发包

本文提供基于区块链的毕业设计国外最新区块链项目源码下载,包括solidity,eth,fabric等blockchain区块链,基于区块链的毕业设计ethoFS SDK – ethoFS软件开发包 是一篇很好的国外资料

ethoFS SDK - ethoFS软件开发包

ethoFS SDK

Official NodeJS SDK for ethoFS

Overview

The ethoFS NodeJS SDK provides the quickest / easiest path for interacting with the ethoFS Network.

Installation

npm install --save @ethofs/sdk 

Setup

To start, simply require the ethoFS SDK and set up an instance with your ethoFS Upload Address/Key. Register a new upload address: ethoFS Uploads.

Initialization Without Authentication

const ethofsSDK = require('@ethofs/sdk'); const ethofs = ethofsSDK();

Initialization With Authentication

const ethofsSDK = require('@ethofs/sdk'); const ethofs = ethofsSDK('yourETHOPrivateKey');

Quickly test that you can connect to the API with the following call:

ethofs.testAuthentication().then((result) => {     //handle successful authentication here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

Usage

Once you’ve set up your instance, using the ethoFS SDK is easy. Simply call your desired function and handle the results of the promise.

Authentication Not Required (ethoFS key not required on initialization)

  • Data
    • networkStats
    • nodeLocations

Authentication Required (ethoFS key required on initialization)

  • User

    • addUser
  • Pinning

    • pinFileToIPFS
    • pinFromFS
    • extendPin
    • unpin
  • Data

    • testAuthentication
    • pinList

### `networkStats` Retrieve ethoFS Network Stats.

ethofs.networkStats()
Params

Response

{     activeUploadContracts: This is number of active upload contracts on the network,     totalNetworkStorageUse: This is total used storage space(in bytes) used on the network,     networkStorageAvailable: This is total used storage space(in bytes) available on the network,     active_gatewaynodes: This is total number of active Gateway Nodes on the network,     active_masternodes: This is total number of active Masternodes on the network,     active_servicenodes: This is total number of active Service Nodes on the network,     gatewaynode_reward: This is the previous daily reward payment for Gateway Nodes,     masternode_reward: This is the previous daily reward payment for Masternodes,     servicenode_reward: This is the previous daily reward payment for Service Nodes } 
Example Code
ethofs.networkStats().then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

nodeLocations

Retrieve ethoFS Node Location Information.

ethofs.nodeLocations()
Params

Response Array

[     {         type: This is type of node (Gateway Node, Masternode, Service Node),         country: This is the country where node is located in,         city: This is the city where node is located in,         latitude: This is the latitude of node (geolocated by IP address),         longitude: This is the longitude of node (geolocated by IP address)     } ] 
Example Code
ethofs.nodeLocations().then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

addUser

Add a new user/address to ethoFS network.

ethofs.addUser(userName)
Params
  • userName – A string of the desired user name for ethoFS registration

Response

{     ethoTXHash: This is transaction hash of the confirmed upload contract on the Ether-1 Network } 
Example Code
var userName = 'TestUserName';  ethofs.addUser(userName).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

pinFileToIPFS

Send a file to ethoFS for direct pinning to IPFS.

ethofs.pinFileToIPFS(readableStream, options)
Params
  • readableStream – A readableStream of the file to be added
  • options : A JSON object that contains the following keyvalues:
    • ethofsData : A JSON object with (#ethofsData-anchor) for the data being pinned
    • ethofsOptions : A JSON object with additional options for the data being pinned

Response

{     ipfsHash: This is the IPFS multi-hash provided back for your content,     ethoTXHash: This is transaction hash of the confirmed upload contract on the Ether-1 Network,     uploadCost: This is the total cost in ETHO for the upload } 
Example Code
const fs = require('fs'); const readableStreamForFile = fs.createReadStream('./yourfile.png'); const options = {     ethofsData: {         name: 'MyCustomUploadName',         keyvalues: {             customKey: 'customValue',             customKey2: 'customValue2'         }     },     ethofsOptions: {         uploadContractDuration: 100000     } }; ethofs.pinFileToIPFS(readableStreamForFile, options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

pinFromFS

Send a file/directory from local filesystem to ethoFS for direct pinning to IPFS.

ethofs.pinFromFS(fsLocation, options)
Params
  • fsLocation – A local filesystem location of the file or directory to be added
  • options : A JSON object that contains the following keyvalues:
    • ethofsData : A JSON object with (#ethofsData-anchor) for the data being pinned
    • ethofsOptions : A JSON object with additional options for the data being pinned

Response

{     ipfsHash: This is the IPFS multi-hash provided back for your content,     ethoTXHash: This is transaction hash of the confirmed upload contract on the Ether-1 Network,     uploadCost: This is the total cost in ETHO for the upload } 
Example Code
const sourceDirectory = ('./yourDirectory'); const options = {     ethofsData: {         name: 'MyCustomDirectoryUploadName',         keyvalues: {             customKey: 'customValue',             customKey2: 'customValue2'         }     },     ethofsOptions: {         uploadContractDuration: 100000     } }; ethofs.pinFromFS(sourceDirectory, options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

unpin

Have ethoFS unpin content that you’ve pinned/uploaded through the platform.

ethofs.extendPin(uploadContractAddress, options)
Params
  • uploadContractAddress – the upload contract address of the content you wish to remove from ethoFS
  • options : A JSON object that contains the following keyvalues:
    • ethofsOptions : A JSON object with (#ethofsOptions-anchor) for the data being extended

Response

{     ethoTXHash: This is transaction hash of the confirmed upload contract extension on the Ether-1 Network } 
Example Code
const options = {     ethofsOptions: {         uploadContractDuration: 100000     } }; ethofs.extendPin(hostingContractAddress, options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

unpin

Have ethoFS unpin content that you’ve pinned/uploaded through the platform.

ethofs.unpin(uploadContractAddress)
Params
  • uploadContractAddress – the upload contract address of the content you wish to remove from ethoFS

Response

{     ethoTXHash: This is transaction hash of the confirmed upload contract removal on the Ether-1 Network } 
Example Code
ethofs.unpin(hashToUnpin).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

testAuthentication

Tests that you can authenticate with ethoFS correctly

ethofs.testAuthentication()
Params

None

Response

{     authenticated: true } 
Example Code
ethofs.testAuthentication().then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

pinList

List pin contracts stored in ethoFS.

ethofs.pinList(options)
Params
  • options (optional) : A JSON object that contains the following keyvalues:
    • ethofsDataFilter (optional) : A JSON object with (#ethofsDataFilter-anchor) for the filtering out pinned data

Response

{     address: This is the Ether-1 contract address,     data: This is any saved data along with upload (ie name/keyvalues),     ipfsHash: This is the IPFS multi-hash provided back for your content,     uploadBlock: This is the original Ether-1 block the upload was iniated/recorded in,     expirationBlock: This is the Ether-1 expiration block of the upload contract } 
Example Code
const options = {     ethofsDataFilter: {         name: 'MyNameFilter',         keyvalues: {             customKeyFilter: 'customValueFilter',             customKey2Filter: 'customValue2Filter'         }     }, }; ethofs.pinList(options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

ethoFS Options

Some endpoints allow you to pass additional options for ethoFS to take into account when adding content to IPFS.

The options object can consist of the following values:

  • uploadContractDuration (required) – The duration in ETHO blocks you would like your upload pinned for. A minimum of 100000 blocks is required.
Example ethofsOptions object
{     uploadContractDuration: 100000 } 

ethoFS Data

Some endpoints allow you to pass additional data to store with your IPFS upload.

The options object can consist of the following values:

  • name (optional) – The name of your upload.
  • keyvalues (optional) – Misc metadata to store with your upload.
Example ethofsData object
{     name: 'UploadContractName',     keyvalues: {         customKey: 'customValue',         customKey2: 'customValue2'     } } 

ethoFS Data Filter

Some endpoints allow you to pass additional data filters to filter out existing contracts.

The options object can consist of the following values:

  • name (optional) – The name of your upload.
  • keyvalues (optional) – Misc metadata stored with your upload.
Example ethofsDataFilter object
{     name: 'UploadContractNameFilter',     keyvalues: {         customKeyFilter: 'customValueFilter',         customKey2Filter: 'customValue2Filter'     } } 

Questions? Issues? Suggestions?

Feel free to file a github issue or email us at admin@ether1.org

We’d love to hear from you!


ethoFS SDK - ethoFS软件开发包

ethoFS SDK

ethoFS的官方NodeJS SDK

概述

ethoFS NodeJS SDK提供了与ethoFS网络交互的最快/最简单的路径。

安装

npm install --save @ethofs/sdk 

无验证初始化

开始时,只需使用ethoFS SDK并使用ethoFS Upload Address/Key设置一个实例即可。注册一个新的上传地址:ethoFS Uploads。

带验证初始化

const ethofsSDK = require('@ethofs/sdk'); const ethofs = ethofsSDK();

用法

const ethofsSDK = require('@ethofs/sdk'); const ethofs = ethofsSDK('yourETHOPrivateKey');

快速测试是否可以通过以下调用连接到API:

ethofs.testAuthentication().then((result) => {     //handle successful authentication here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

不需要验证(初始化时不需要ethoFS密钥)

一旦设置了实例,使用ethoFS SDK就很容易了。只需调用所需函数并处理承诺的结果。

需要验证(初始化时需要ethoFS密钥初始化)

  • testAuthentication

ethofs.networkStats()

  • readableStream-要添加的文件的readableStream
  • ethofsOptions:一个JSON对象,为被pinned的数据提供附加选项
  • ethofsDataFilter(可选):JSON对象(#ethofsDataFilter anchor)用于筛选出固定数据

### `networkStats` Retrieve ethoFS Network Stats.

参数
响应

示例代码

{     activeUploadContracts: This is number of active upload contracts on the network,     totalNetworkStorageUse: This is total used storage space(in bytes) used on the network,     networkStorageAvailable: This is total used storage space(in bytes) available on the network,     active_gatewaynodes: This is total number of active Gateway Nodes on the network,     active_masternodes: This is total number of active Masternodes on the network,     active_servicenodes: This is total number of active Service Nodes on the network,     gatewaynode_reward: This is the previous daily reward payment for Gateway Nodes,     masternode_reward: This is the previous daily reward payment for Masternodes,     servicenode_reward: This is the previous daily reward payment for Service Nodes } 
节点位置
ethofs.networkStats().then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

节点位置()

检索ethoFS节点位置信息。

参数
响应数组

示例代码

[     {         type: This is type of node (Gateway Node, Masternode, Service Node),         country: This is the country where node is located in,         city: This is the city where node is located in,         latitude: This is the latitude of node (geolocated by IP address),         longitude: This is the longitude of node (geolocated by IP address)     } ] 
添加用户
ethofs.nodeLocations().then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

ethofs.addUser文件(用户名)

向ethoFS网络添加新用户/地址。

参数
响应
  • keyvalues(可选)-要与上载一起存储的杂项元数据。

参数

{     ethoTXHash: This is transaction hash of the confirmed upload contract on the Ether-1 Network } 
响应
var userName = 'TestUserName';  ethofs.addUser(userName).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

示例代码

将文件发送到ethoFS以直接固定到IPFS。

pinFromFS
ethofs.pinFromFS公司(f)位置,选项)
  • 名称(可选)-上载的名称。
  • keyvalues(可选)-上传时存储的杂项元数据。你知道吗

参数

{     ipfsHash: This is the IPFS multi-hash provided back for your content,     ethoTXHash: This is transaction hash of the confirmed upload contract on the Ether-1 Network,     uploadCost: This is the total cost in ETHO for the upload } 
响应
const fs = require('fs'); const readableStreamForFile = fs.createReadStream('./yourfile.png'); const options = {     ethofsData: {         name: 'MyCustomUploadName',         keyvalues: {             customKey: 'customValue',             customKey2: 'customValue2'         }     },     ethofsOptions: {         uploadContractDuration: 100000     } }; ethofs.pinFileToIPFS(readableStreamForFile, options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

示例代码

将文件/目录从本地文件系统发送到ethoFS,以便直接固定到IPFS。

取消固定
延伸管(uploadContractAddress,选项)
  • fsLocation – A local filesystem location of the file or directory to be added
  • options : A JSON object that contains the following keyvalues:
    • ethofsData : A JSON object with (#ethofsData-anchor) for the data being pinned
    • ethofsOptions : A JSON object with additional options for the data being pinned

参数

{     ipfsHash: This is the IPFS multi-hash provided back for your content,     ethoTXHash: This is transaction hash of the confirmed upload contract on the Ether-1 Network,     uploadCost: This is the total cost in ETHO for the upload } 
响应
const sourceDirectory = ('./yourDirectory'); const options = {     ethofsData: {         name: 'MyCustomDirectoryUploadName',         keyvalues: {             customKey: 'customValue',             customKey2: 'customValue2'         }     },     ethofsOptions: {         uploadContractDuration: 100000     } }; ethofs.pinFromFS(sourceDirectory, options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

示例代码

取消固定通过平台固定/上传的内容。

取消固定
ethofs.unpin公司(uploadContractAddress)
  • uploadContractAddress – the upload contract address of the content you wish to remove from ethoFS
  • options : A JSON object that contains the following keyvalues:
    • ethofsOptions : A JSON object with (#ethofsOptions-anchor) for the data being extended

参数

{     ethoTXHash: This is transaction hash of the confirmed upload contract extension on the Ether-1 Network } 
响应
const options = {     ethofsOptions: {         uploadContractDuration: 100000     } }; ethofs.extendPin(hostingContractAddress, options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

示例代码

取消固定通过平台固定/上传的内容。

测试验证
ethofs.testAuthentication测试验证()
  • uploadContractAddress – the upload contract address of the content you wish to remove from ethoFS

参数

{     ethoTXHash: This is transaction hash of the confirmed upload contract removal on the Ether-1 Network } 
响应
ethofs.unpin(hashToUnpin).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

示例代码

测试您是否可以正确地使用ethoFS进行身份验证

pinList
ethofs.pinList文件(选项)

参数

{     authenticated: true } 
响应
ethofs.testAuthentication().then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

示例代码

列出存储在ethoFS中的pin协定。

ethoFS选项
示例ethofsOptions对象
  • options (optional) : A JSON object that contains the following keyvalues:
    • ethofsDataFilter (optional) : A JSON object with (#ethofsDataFilter-anchor) for the filtering out pinned data

ethoFS数据

{     address: This is the Ether-1 contract address,     data: This is any saved data along with upload (ie name/keyvalues),     ipfsHash: This is the IPFS multi-hash provided back for your content,     uploadBlock: This is the original Ether-1 block the upload was iniated/recorded in,     expirationBlock: This is the Ether-1 expiration block of the upload contract } 
示例ethofsData object
const options = {     ethofsDataFilter: {         name: 'MyNameFilter',         keyvalues: {             customKeyFilter: 'customValueFilter',             customKey2Filter: 'customValue2Filter'         }     }, }; ethofs.pinList(options).then((result) => {     //handle results here     console.log(result); }).catch((err) => {     //handle error here     console.log(err); });

ethoFS Data Filter

某些终结点允许您为ethoFS传递在向IPFS添加内容时要考虑的其他选项。

选项对象可以由以下值组成:

  • uploadContractDuration (required) – The duration in ETHO blocks you would like your upload pinned for. A minimum of 100000 blocks is required.
示例ethofsDataFilter object
{     uploadContractDuration: 100000 } 

问题?问题?建议?数据网络统计节点位置
  • testAuthentication
  • pinList
  • 用户名-用于ethoFS注册的所需用户名的字符串
  • readableStream-要添加的文件的readableStream
  • 选项:包含以下键值的JSON对象:ethofsData:具有(#ethofsData anchor)的JSON对象,用于要添加的数据pinned ethofsOptions:一个JSON对象,为被pinned的数据提供附加选项:一个JSON对象,为被pinned的数据提供(#ethofsData anchor)
  • ethofsOptions:一个JSON对象,为被pinned的数据提供附加选项
  • fsLocation-文件或文件的本地文件系统位置要添加的目录选项:包含以下键值的JSON对象:ethofsData:对于要固定的数据具有(#ethofsData anchor)的JSON对象ethofsOptions:对于要固定的数据具有附加选项的JSON对象:对于要固定的数据具有(#ethofsData anchor)的JSON对象
  • ethofsOptions:一个JSON对象,其中包含用于固定数据的附加选项
  • uploadContractAddress—要从ethoFS中删除的内容的上载约定地址
  • options:一个JSON对象,其中包含以下键值:ethofsOptions:一个JSON对象,其中(#ethofsOptions anchor)用于正在扩展的数据ethofsOptions:一个JSON对象,其中(#ethofsOptions anchor)表示正在扩展的数据uploadContractAddress-要从ethofsOptions中删除的内容的上载协定地址(可选):一个JSON对象,包含以下键值:ethofsDataFilter(可选):AJSON对象(#ethofsDataFilter anchor)用于筛选出固定数据
  • ethofsDataFilter(可选):JSON对象(#ethofsDataFilter anchor)用于筛选出固定数据
  • uploadContractDuration(必需)-您希望为其固定上载的ETHO块中的持续时间。至少需要100000个街区。
  • 名称(可选)-上载的名称。
  • keyvalues(可选)-要与上载一起存储的杂项元数据。
  • 名称(可选)-上载的名称。
  • keyvalues(可选)-上传时存储的杂项元数据。你知道吗
  • 某些端点允许您通过IPFS上载传递附加数据以存储。

    选项对象可以由以下值组成:

    • name (optional) – The name of your upload.
    • keyvalues (optional) – Misc metadata to store with your upload.
    Example ethofsData object
    {     name: 'UploadContractName',     keyvalues: {         customKey: 'customValue',         customKey2: 'customValue2'     } } 

    ethoFS Data Filter

    某些端点允许您传递其他数据筛选器以筛选出现有协定。

    选项对象可以由以下值组成:

    • name (optional) – The name of your upload.
    • keyvalues (optional) – Misc metadata stored with your upload.
    Example ethofsDataFilter object
    {     name: 'UploadContractNameFilter',     keyvalues: {         customKeyFilter: 'customValueFilter',         customKey2Filter: 'customValue2Filter'     } } 

    Questions? Issues? Suggestions?

    请随时提交github问题或发送电子邮件至admin@ether1.org

    我们很高兴收到您的来信!

    部分转自网络,侵权联系删除区块链源码网

    www.interchains.cc

    https://www.interchains.cc/20869.html

    区块链毕设网(www.interchains.cc)全网最靠谱的原创区块链毕设代做网站 部分资料来自网络,侵权联系删除! 最全最大的区块链源码站 ! QQ3039046426
    区块链知识分享网, 以太坊dapp资源网, 区块链教程, fabric教程下载, 区块链书籍下载, 区块链资料下载, 区块链视频教程下载, 区块链基础教程, 区块链入门教程, 区块链资源 » 基于区块链的毕业设计ethoFS SDK – ethoFS软件开发包

    提供最优质的资源集合

    立即查看 了解详情