This repository is obsolete, use https://github.com/DECENTfoundation/dcorejs
Quick look into DECENT
The new way of publishing
Our intention is to revolutionize digital distribution across the Internet.
DECENT Network is a content distribution platform that is decentralized, open-source and uses Blockchain technology. Blockchain technology guarantees trust and security by embedding encryption at the lowest level. Perhaps the greatest benefit of this implementation of blockchain technology is invariant storage for published content which can eliminate manipulation and influence by any sort of middleman (eg. publisher). In short content can now be created and delivered directly with any fees collected solely by the seller at the point of sale. In addition to the technological side, there are the economical and social protocols that will govern real-world interactions across the network. In order to make transactions viable and user friendly a crypto-token, the DCT, has been implemented. The encrypted DCT tokens help mitigate attacks, promote funding and ensure transaction validation. One last thing of note, unlike other content distribution platforms underdevelopment, there are virtually no limitations as to the type of media that can be published on DECENT Network. It could be songs, books, articles, videos, source code, or anything really and in almost any format.
decent-js
Javascript library to work with Decent blockchain network.
Quick start
Installation
-
Install
Node.js >6
andnpm >3
globally -
Change directory to project root dir
-
Install
npm install decent-js
-
Install decentjs-lib dependency library using
npm install git+ssh://git@github.com/DECENTfoundation/decentjs-lib
Initialize library
; ; ; decent.initializeconfig, DecentjsLib;
Replace decent_network_wspaths
with active decent daemon instance and chain_id
with blockchain id which
you are about to work on.
Usage
Once Decent lib is initialized, you can access methods using Decent.instance().core
Search content
; ; ; ; ; ; ; ; ; decent.content.searchContentsearchParams .then .catch;
Replace all variables with your values to get requested content. Search example
Buy content
; ; ; ; ; decent.content.buyContent contentId, accountId, elGammalPublic, privateKey .then .catch;
Replace variables with keys from your decent account to buy content. Otherwise you will not be able to buy content. Private key must be in WIF(Wallet Import Format). Buy example
Download/Restore content
Method restoreContentKeys
will restore your key generated during content submission, used to encrypt content.
; ; ; ; ; // Content key restoration decent.content.restoreContentKeyscontentId, elGamalKeyPair .then .catch;
More examples available here.
To run examples, you need to clone repository and build with npm run pack
. Browser bundle will be found
within dist/bundle.js
. Node version in lib/decent-js.js
.
All available methods
Content
searchContent(searchParams: SearchParams): Promise<Content[]>
getContent(id: string): Promise<Content>
removeContent(contentId: string, authorId: string, privateKey: string): Promise<void>
restoreContentKeys(contentId: String, accountId: string, ...elGamalKeys: KeyPair[]): Promise<string>
generateContentKeys(seeders: string[]): Promise<ContentKeys>
addContent(content: SubmitObject, privateKey: string): Promise<void>
buyContent(contentId: string, buyerId: string, elGammalPub: string, privateKey: string): Promise<void>
getSeeders(resultSize: number): Promise<Seeder[]>
getPurchasedContent(accountId: string, order: string, startObjectId: string, term: string, resultSize: number): Promise<Content[]>
Account
getAccountByName(name: string): Promise<Account>
getAccountById(id: string): Promise<Account>
getTransactionHistory(accountId: string, privateKeys: string[],order: string, startObjectId: string, resultLimit: number): Promise<TransactionRecord[]>
transfer(amount: number, fromAccount: string, toAccount: string, memo: string, privateKey: string): Promise<void>
getBalance(account: string): Promise<number>