This package has been deprecated

Author message:

Deprecated library, use dcorejs-sdk instead

dcorejs
TypeScript icon, indicating that this package has built-in type declarations

5.2.0 • Public • Published

Quick look into DECENT

The new way of publishing

Our intention is to revolutionize digital distribution across the Internet.

DCore 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 Dcore Network. It could be songs, books, articles, videos, source code, or anything really and in almost any format.

dcorejs

Javascript library for browser and node.js to work with Dcore blockchain network. Supported browsers versions:

  • Chrome - > 54
  • Firefox - > 58
  • Safari - > 11
  • Edge - > 41

Quick start

Installation

  1. Install Node.js >6 and npm >3 globally

  2. For Windows you need to install node-gyp build tool.

  3. Change directory to project root dir

  4. Install npm install dcorejs

### Customization

In case you want to customize library and generate documentation for code use command npm run generate-docs. Documentation will be generated in ./dist/docs folder.

Initialize library

Server

import * as dcorejs from 'dcorejs';
 
const config = {
    dcoreNetworkWSPaths: ['wss://your.dcore.daemon:8090'],
    chainId: 'your-dcore-chain-id'
};
 
dcorejs.initialize(config);

NOTE: If running server from localhost add NODE_TLS_REJECT_UNAUTHORIZED=0 before library initialization.

If you want debug logs during development, before running your application set ENVIRONMENT variable to DEV. For websocket debug logs set WS_ENV variable to DEV.

Browser

    <script src="./dcorejs.umd.js" type="text/javascript"></script> 
    <script type="text/javascript">
        var testConnection = false;
        var chainId = 'your-dcore-chain-id';
        var dcoreNetworkAddresses = ['wss://your.dcore.daemon:8090'];
        
        dcorejs.initialize(
            {
                chainId: chainId, 
                dcoreNetworkWSPaths: dcoreNetworkAddresses
            }, 
            testConnection);
    </script> 

NOTE: Use testConnection = false if CORS problem appear.

Replace dcoreNetworkWSPaths with active dcore daemon instance and chainId with blockchain id which you are about to work on.

Usage

Once dcore lib is initialized, you can access methods using dcorejs with any of submodule - account(), asset(), content(), explorer(), messaging(), mining(), proposal(), seeding() or subscription()

Connection control

Library dcorejs offer methods to control connection.

import * as dcorejs from 'dcorejs';
 
const connection = dcorejs.connection();
 
// ...
 
connection.closeConnection();
 
// ...
 
connection.openConnection()
    .then(res => {
        // connection opened, connection.isConnected === true
    })

Create account

There is two ways how to create account in DCore network: Account.registerAccount and Account.createAccountWithBrainkey.
Recomended way to create account is using Account.registerAccount method, because there is option to set keys to be different. Also can use Account.createAccountWithBrainkey, but keys generated from brainkey for ownerKey, activeKey and memoKey will be the same, which is not recommended for security reasons.

import * as dcorejs from 'dcorejs';
import { KeyPrivate, KeyPublic, Utils } from 'dcorejs';
 
let sequenceNumber = 0;
const brainKey = dcorejs.account().suggestBrainKey();
// owner key is generated with sequenceNumber = 0
const [, publicOwnerKey]: [KeyPrivate, KeyPublic] = Utils.generateKeys(brainKey);
const privateActiveKey: KeyPrivate = Utils.derivePrivateKey(brainKey, sequenceNumber + 1);
const privateMemoKey: KeyPrivate = Utils.derivePrivateKey(brainKey, sequenceNumber + 2);
const registrarPrivateKey = '5KcA6ky4Hs9VoDUSdTF4o3a2QDgiiG5gkpLLysRWR8dy6EAgTni';
 
const publicActiveKey: KeyPublic = KeyPublic.fromPrivateKey(privateActiveKey)
const publicMemoKey: KeyPublic = KeyPublic.fromPrivateKey(privateMemoKey)
 
const accountId = '1.1.1'
 
dcorejs.account().registerAccount(
    'myNewAccountName',
    publicOwnerKey.stringKey,
    publicActiveKey.stringKey,
    publicMemoKey.stringKey,
    accountId,
    registrarPrivateKey)
    .then(res => {
        // account_create transaction was successfully broadcasted
    })
    .catch(err => {
        // error broadcasting transaction
    });

NOTE: Make sure, that sequenceNumber you generating keys with, was not used for generating keys for your accounts in past.

Submit content

import * as dcorejs from 'dcorejs';
 
const privateKey = '5KcA6ky4Hs9VoDUSdTF4o3a2QDgiiG5gkpLLysRWR8dy6EAgTni';
dcorejs.content().generateContentKeys(seederIds)
    .then((contentKeys: dcorejs.ContentKeys) => {
        const submitObject: SubmitObject = {
            authorId: "1.2.345",
            coAuthors: [["1.2.456", 1000]],
            seeders: [],
            fileName: "wallet-export.json",
            date: "2018-09-30T22:00:00.000Z",
            price: 134,
            size: 2386,
            URI: "http://test.uri.com",
            hash: "014abb5fcbb2db96baf317f2f039e736c95a5269",
            keyParts: [],
            synopsis: {
                title: "Foo book",
                description: "This book is about Fooing",
                content_type_id: "1.3.6.0"
            },
            assetId: "1.3.0",
            publishingFeeAsset: "1.3.0"
        };
        dcorejs.content().addContent(submitObject, privateKey)
            .then(res => {
                // content successfully submitted
            })
            .catch(err => {
                // error occured during content submition
            })
    })
    .catch(err => {
        // error occured during content uploading
    })

Example shown above is for case when content is already uploaded to seeders using DCore IPFS node. It is also possible to submit content uploaded to different storage (e.g. CDN). Then omit parameters seeders and keyParts, and use empty arrays instead.

Note following:

  • Each newly submitted content must have unique URI.

  • If submitting content with same URI, then parameters hash, author, date, seeders and keyParts must stay same. All other data are updated.

  • Hash needs to be RIPEMD-160, and can be generated using dcorejs.Utils.ripemdHash() method

  • Synopsis need to contain at least parameters title, description and content_type_id. content_type_id is composed of '<app_id>.<category>.<sub_category>.<is_adult_content>', for example 1.1.2.0.

Search content

import * as dcorejs from 'dcorejs';
 
const term = 'some phrase';
const order = dcorejs.SearchParamsOrder.createdDesc;
const user = '1.2.345';
const region_code = 'en';
const itemId = '0.0.0';
const category = '1';
const count = 4;
 
const searchParams: dcorejs.SearchParams = {
    term, 
    order,
    user, 
    region_code, 
    itemId, 
    category, 
    count 
}
 
dcorejs.content().searchContent(searchParams)
    .then((contents: dcorejs.Content[]) => {
        // process found content
    })
    .catch(err => {
        // handle error
    });

Replace all variables with your values to get requested content. Search browser example

Buy content

import * as dcorejs from 'dcorejs';
 
const contentId = '2.13.54';
const accountId = '1.2.45';
const privateKey = 'ac7b6876b8a7b68a7c6b8a7c6b8a7cb68a7cb78a6cb8';
const elGammalPublic = '704978309485720398475187405981709436818374592763459872645';
 
dcorejs.content()
    .buyContent(contentId,
                accountId,
                elGammalPublic,
                privateKey)
    .then(() => {
        // Content successfully bought
    })
    .catch(() => {
        // buy unsuccessful, handle buy error
    });

Replace variables with keys from your dcore account to buy content. Otherwise you will not be able to buy content. Private key must be in WIF(Wallet Import Format). Buy browser example

Download/Restore content

Method restoreContentKeys will restore your key generated during content submission, used to encrypt content.

import * as dcorejs from 'dcorejs';
 
const elGamalPrivate = '32983749287349872934792739472387492387492834';
const elGamalPublic = '704978309485720398475187405981709436818374592763459872645';
const elGamalKeyPair = new dcorejs.KeyPair(elGamalPrivate, elGamalPublic);
const contentId = '2.13.312';
const accountId = '1.2.345';
 
// Content key restoration
dcorejs.content().restoreContentKeys(contentId, accountId, elGamalKeyPair)
    .then(key => {
        // ... now you are able to decrypt your content
    })
    .catch(err => {
        // error restoring key
    });

Download browser example

Blockchain event handling

dcorejs.subscribe((data: any) => {
    // handle fired event
}).then(subscription => {
    // subscription object
});
 
dcorejs.subscribePendingTransaction((data: dcorejs.Block.Transaction) => {
    // handle pending transaction event
}).then(subscription => {
    // subscription object
});
 
dcorejs.subscribeBlockApplied((data: number) => {
    // handle block applied event
}).then(subscription => {
    // subscription object
});

Custom transaction

In case you want to create custom transaction, see following example. Replace 'X' values and private key for your own.

import * as dcorejs from 'dcorejs';
 
const operation = new dcorejs.TransactionOperations.AssetFundPools(
    '1.2.X',
    {
        amount: 10,
        asset_id: '1.3.X'
    },
    {
        amount: 1,
        asset_id: '1.3.0'
    }
);
const privateKey = 'yourPrivateKey';
const transactionBuilder = dcorejs.transactionBuilder();
const result = transactionBuilder.addOperation(operation);
if (result === '') {
    transactionBuilder.broadcast(privateKey)
        .then(result => {
            console.log(result);
        })
        .catch(error => {
            console.log(error);
        });
} else {
    console.error(result);
}

More examples available here. To run examples, you need to clone repository and build with npm run build if folders dist and lib is not presented. Browser bundle can be found within dist/dcorejs.umd.js. Node version in lib/dcorejs.js.

All available methods

dcorejs

subscribe(callbackChainSubscriptionCallback)
subscribeBlockApplied(callbackChainSubscriptionBlockAppliedCallback) 
subscribePendingTransaction(callbackChainSubscriptionCallback) 
content()ContentModule 
account()AccountModule 
explorer()ExplorerModule 
asset()AssetModule 
mining()MiningModule 
subscription()SubscriptionModule 
seeding()SeedingModule 
proposal()ProposalModule 
messaging()MessagingModule 
transactionBuilder()TransactionBuilder 
connection()ApiConnector

Content

searchContent(searchParams?: SearchParams, convertAssetboolean = false)Promise<Content[]>
getContent(idstring, convertAssetboolean = false)Promise<ContentObject>
getContentURI(URIstring, convertAssetboolean = false)Promise<ContentObject | null>
removeContent(contentIdstring,
        authorIdstring,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
restoreContentKeys(contentIdstring, accountIdstring, ...elGamalKeysKeyPair[])Promise<string>
generateContentKeys(seedersstring[])Promise<ContentKeys>
addContent(contentSubmitObject, privateKeystring, broadcastboolean = true)Promise<Operation>
getOpenBuying(convertAssetboolean = false)Promise<BuyingContent[]>
getOpenBuyingByURI(URIstring, convertAssetboolean = false)Promise<BuyingContent[]>
getOpenBuyingByConsumer(accountIdstring, convertAssetboolean = false)Promise<BuyingContent[]>
getBuyingByConsumerURI(accountIdstring, URIstring, convertAssetboolean = false)Promise<BuyingContent[] | null>
getBuyingHistoryObjectsByConsumer(accountIdstring, convertAssetboolean = false)Promise<BuyingContent[]>
buyContent(contentIdstring,
        buyerIdstring,
        elGammalPubstring,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
getSeeders(resultSizenumber = 100)Promise<Seeder[]>
getPurchasedContent(accountIdstring,
        orderSearchParamsOrder = SearchParamsOrder.createdDesc,
        startObjectIdstring = '0.0.0',
        termstring = '',
        resultSizenumber = 100)Promise<Content[]>
getRating(contentIdstring, forUserstring, ratingStartIdstring = '', countnumber = 100)Promise<Array<BuyingContent>>
searchFeedback(accountIdstring, contentURIstring, ratingStartIdstring, countnumber = 100)Promise<Array<BuyingContent>>
getAuthorCoAuthors(URIstring)Promise<[string, string[]] | null>
leaveCommentAndRating(contentURIstring,
        consumerstring,
        commentstring,
        ratingnumber,
        consumerPKeystring,
        broadcastboolean = true)Promise<Operation>
 

Account

getAccountByName(namestring)Promise<Account>
getAccountById(idstring)Promise<Account>
getTransactionHistory(accountIdstring,
        privateKeysstring[] = [],
        orderSearchAccountHistoryOrder = SearchAccountHistoryOrder.timeDesc,
        startObjectIdstring = '0.0.0',
        resultLimitnumber = 100)Promise<TransactionRecord[]>
searchAccountHistory(accountIdstring,
        privateKeysstring[] = [],
        orderSearchAccountHistoryOrder = SearchAccountHistoryOrder.timeDesc,
        startObjectIdstring = '0.0.0',
        resultLimitnumber = 100,
        convertAssetsboolean = false)Promise<TransactionRecord[]>
transfer(amountnumber,
        assetIdstring,
        fromAccountstring,
        toAccountstring,
        memostring,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
getBalance(accountIdstring, assetIdstring = '1.3.0', convertAssetboolean = false)Promise<number>
isTransactionConfirmed(accountIdstring, transactionIdstring)Promise<boolean>
getAccountHistory(accountIdstring, historyOptions?: HistoryOptions)Promise<HistoryRecord[]>
searchAccounts(searchTermstring = '',
        orderAccountOrder = AccountOrder.none,
        idstring = '0.0.0',
        limitnumber = 100)Promise<Account>
getAccountCount()Promise<number>
registerAccount(namestring,
        ownerKeystring,
        activeKeystring,
        memoKeystring,
        registrarstring,
        registrarPrivateKeystring,
        broadcastboolean = true)Promise<Operation>
createAccountWithBrainkey(brainkeystring, 
        accountNamestring,
        registrarstring,
        registrarPrivateKeystring)Promise<Operation>
listAccounts(lowerBoundstring = '', limitnumber = 100)Promise<AccountNameIdPair[]>
listAccountBalances(idstring, convertAssetsboolean = false)Promise<Asset[]>
searchMinerVoting(accountNamestring, 
        keywordstring,
        myVotesboolean = true,
        sortMinerOrder = MinerOrder.none,
        fromMinerIdstring = '',
        limitnumber = 1000)Promise<MinerInfo[]>
updateAccount(accountIdstring, paramsUpdateAccountParameters, privateKeystring, broadcastboolean = true)Promise<Operation>
searchAccountBalanceHistory(accountIdstring,
        assetListstring[] = [],
        partnerIdstring = null,
        fromBlockNumbernumber = null,
        toBlockNumbernumber = null,
        offsetnumber = 0,
        limitnumber = 100)Promise<HistoryBalanceObject[]>
getAccountBalanceForTransaction(accountIdstring, historyIdstring)Promise<HistoryBalanceObject>
getTransactionById(transactionIdstring)Promise<any>

Asset

listAssets(lowerBoundSymbolstring,
        limitnumber = 100,
        UIAOnlyboolean = false,
        formatAssetsboolean = false)Promise<AssetObject[]>
createUserIssuedAsset(issuerstring,
        symbolstring,
        precisionnumber,
        descriptionstring,
        maxSupplynumber,
        baseExchangeAmountnumber,
        quoteExchangeAmountnumber,
        isExchangeableboolean,
        isSupplyFixedboolean,
        issuerPrivateKeystring,
        broadcastboolean = true)Promise<Operation>
issueAsset(assetSymbolstring,
        amountnumber,
        issueToAccountstring,
        memostring,
        issuerPKeystring,
        broadcastboolean = true)Promise<Operation>
updateUserIssuedAsset(symbolstring,
        newInfoUserIssuedAssetInfo,
        issuerPKeystring,
        broadcastboolean = true)Promise<Operation>
fundAssetPools(fromAccountIdstring,
        uiaAmountnumber,
        uiaSymbolstring,
        dctAmountnumber,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
assetReserve(payerstring,
        symbolstring,
        amountToReservenumber,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
assetClaimFees(issuerstring,
        uiaAmountnumber,
        uiaSymbolstring,
        dctAmountnumber,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
getAsset(assetIdstring, formatAssetboolean = false)Promise<DCoreAssetObject>
getAssets(assetIdsstring[], formatAssetsboolean = false)Promise<DCoreAssetObject[]>
priceToDCT(symbolstring, amountnumber)Promise<Asset>
publishAssetFeed(publishingAccountstring,
        symbolstring,
        exchangeBaseAmountnumber,
        exchangeQuoteAmountnumber,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
getFeedsByMiner(minerAccountIdstring, limitnumber = 100)Promise<any>
getRealSupply()Promise<RealSupply>
getMonitoredAssetData(assetIdstring)Promise<MonitoredAssetOptions | null>
createMonitoredAsset(issuerstring,
        symbolstring,
        precisionnumber,
        descriptionstring,
        feedLifetimeSecnumber,
        minimumFeedsnumber,
        issuerPrivateKeystring,
        broadcastboolean = true)Promise<Operation>
updateMonitoredAsset(symbolstring, 
        descriptionstring, 
        feedLifetimeSecnumber,
        minimumFeedsnumber, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>

Explorer

getObject(objectIdstring)Promise<any>
getAccount(idstring)Promise<Account>
getAsset(idstring)Promise<Block.Asset>
getWitness(idstring)Promise<Block.Miner>
getOperationHistory(idstring)Promise<Block.Transaction>
getVestingBalance(idstring)Promise<Block.VestingBalance>
getAssetDynamicDataType(idstring)Promise<Block.AssetDynamicProperty>
getAccountBalance(idstring)Promise<Block.AccountBalance>
getAccountStatistics(idstring)Promise<Block.AccountStatistics>
getBlockSummary(idstring)Promise<Block.BlockSummary>
getAccountTransactionHistory(idstring)Promise<Block.AccountTransactionHistory>
getChainProperty(idstring)Promise<Block.ChainProperty>
getMinerSchedule(idstring)Promise<Block.MinerSchedule>
getBudgetRecord(idstring)Promise<Block.BudgetReport>
getBuying(idstring)Promise<Block.Buying>
getContent(idstring)Promise<Block.Content>
getPublisher(idstring)Promise<Block.Publisher>
getSubscription(idstring)Promise<Block.Subscription>
getSeedingStatistics(idstring)Promise<Block.SeedingStatistics>
getTransactionDetail(idstring)Promise<Block.TransactionDetail>
getBlock(idnumber)Promise<Block.Block>
getBlocks(idnumber, countnumber)Promise<Array<Block.Block>>
getAccounts(idsstring[])Promise<Array<Account>>
getTransaction(blockNonumber, txNumnumber)Promise<Block.Transaction>
getMiners(idsstring[])Promise<Array<Miner>>
getMiner(idstring)Promise<Miner|null>

Mining

setDesiredMinerCount(accountIdstring, 
        desiredNumOfMinersnumber, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
createMiner(minerAccountIdstring, 
        URLstring, 
        signingPublicKeystring, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
unvoteMiner(minerstring, accountstring, privateKeyWifstring, broadcastboolean = true)Promise<Operation>
unvoteMiners(minersstring[], accountstring, privateKeyWifstring, broadcastboolean = true)Promise<Operation>
voteForMiner(minerstring, accountstring, privateKeyWifstring, broadcastboolean = true)Promise<Operation>
voteForMiners(minersstring[], accountstring, privateKeyWifstring, broadcastboolean = true)Promise<Operation>
voteUnvoteMiners(voteMinersstring[], 
        unvoteMinersstring[], 
        accountIdstring, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
getVestingBalances(accountIdstring)Promise<VestingBalance[]>
updateMiner(minerIdstring, 
        minerAccountIdstring, 
        updateDataMinerUpdateData, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
withdrawVesting(vestinBalanceIdstring,
        ownerIdstring,
        amountnumber,
        assetIdstring,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
setVotingProxy(accountIdstring, votingAccountIdstring, privateKeystring, broadcastboolean = true)Promise<Operation>
listMiners(fromIdstring, limitnumber = 100)Promise<MinerNameIdPair[]>
getMiner(minerIdstring)Promise<Miner>

Proposal

getProposedTransactions(accountIdstring)Promise<ProposalObject[]>
proposeTransfer(proposerAccountIdstring, 
        fromAccountIdstring, 
        toAccountIdstring, 
        amountnumber, 
        assetIdstring, 
        memoKeystring,
        expirationstring, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
proposeParameterChange(proposerAccountIdstring, 
        proposalParametersProposalParameters, 
        expirationstring, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
proposeFeeChange(proposerAccountIdstring, 
        feesParametersFeesParameters, 
        expirationstring, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
approveProposal(payingAccountIdstring, 
        proposalIdstring, 
        approvalsDeltaDeltaParameters, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>

Seeding

listSeedersByPrice(limitnumber = 100)Promise<Seeder[]>
listSeedersByUpload(limitnumber = 100)Promise<Seeder[]>
listSeedersByRegion(regionstring)Promise<Seeder[]>
listSeedersByRating(limitnumber = 100)Promise<Seeder[]>

Subscription

listActiveSubscriptionsByConsumer(consumerIdstring, countnumber = 100)Promise<SubscriptionObject[]> {
listSubscriptionsByConsumer(consumerIdstring, countnumber = 100)Promise<SubscriptionObject[]> {
listActiveSubscriptionsByAuthor(authorIdstring, countnumber = 100)Promise<SubscriptionObject[]> {
listSubscriptionsByAuthor(authorIdstring, countnumber = 100)Promise<SubscriptionObject[]> {
subscribeToAuthor(fromstring, 
        tostring, 
        amountnumber, 
        assetIdstring, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
subscribeByAuthor(fromstring, tostring, privateKeystring, broadcastboolean = true)Promise<Operation> {
setAutomaticRenewalOfSubscription(accountIdstring, 
        subscriptionIdstring, 
        automaticRenewalboolean, 
        privateKeystring, 
        broadcastboolean = true)Promise<Operation>
setSubscription(accountIdstring, 
        optionsSubscriptionOptions,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>

Messaging

getSentMessages(senderstring, decryptPrivateKeystring = '', countnumber = 100)Promise<IDCoreMessagePayload[]>
getMessages(receiverstring, decryptPrivateKeystring = '', countnumber = 100)Promise<IDCoreMessagePayload[]>
getMessageObjects(senderstring = '',
sendMessage(senderstring,
        receiverIdstring,
        messagestring,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>
sendUnencryptedMessage(senderstring,
        receiverIdstring,
        messagestring,
        privateKeystring,
        broadcastboolean = true)Promise<Operation>

Utils

formatToReadiblePrice(dctAmountnumber)string
formatAmountForDCTAsset(amountnumber)number
formatAmountForAsset(amountnumber, assetDCoreAssetObject)number
formatAmountToAsset(amountnumber, assetDCoreAssetObject)number
ripemdHash(fromBufferstring)string
generateKeys(fromBrainKeystring)[KeyPrivate, KeyPublic]
getPublicKey(privateKeystring)KeyPublic
privateKeyFromWif(pkWifstring)KeyPrivate
publicKeyFromString(pubKeyStringstring)KeyPublic
suggestBrainKey()string
getBrainKeyInfo(brainKeystring)BrainKeyInfo
normalize(brainKeystring)string
generateNonce()string
elGamalPublic(elGamalPrivatestring)string
elGamalPrivate(privateKeyWifstring)string
generateElGamalKeys(privateKeyWifstring)ElGamalKeys
generateBrainKeyElGamalKey()[BrainKeyInfo, ElGamalKeys]
derivePrivateKey(brainKeystring, sequencenumber)KeyPrivate

Crypto utils

encryptWithChecksum(messagestring,
        privateKeystring,
        publicKeystring,
        noncestring = '')string
decryptWithChecksum(messagestring,
        privateKeystring,
        publicKeystring,
        noncestring = '')string
ripemdHash(fromBufferstring)string
md5(messagestring)string
sha512(messagestring)string
sha256(messagestring)string
encrypt(messagestring, passwordstring)string
decrypt(messagestring, passwordstring)string | null
encryptToHexString(messagestring | Buffer, passwordstring)string
decryptHexString(messagestring, passwordstring)string

Transaction builder

addOperation(operationOperation)void
propose(proposalParametersProposalCreateParameters)void
broadcast(privateKeystring, signboolean = true)Promise<void>
setTransactionFees()Promise<void>
signTransaction(privateKeyKeyPrivate)void
replaceOperation(operationIndexnumber, newOperationOperation)boolean
previewTransaction()any

Dependents (0)

Package Sidebar

Install

npm i dcorejs

Weekly Downloads

0

Version

5.2.0

License

MIT

Unpacked Size

16.2 MB

Total Files

534

Last publish

Collaborators

  • peter.student
  • peter.vanderka