Commit 94a4e2f8 authored by Mahdi Yari's avatar Mahdi Yari

Merge branch 'fix-browserbuild-readme-1' into 'master'

Fix browserbuild and readme

See merge request !4
parents 3ebac6da c21cbf88
......@@ -11,7 +11,7 @@ build/Release
node_modules
.tern-port
dist/steem-tests.min.js*
dist/hive-tests.min.js*
# node-dist
.tern-port
.envrc
......
MIT License
Copyright (c) 2017 Steem.js
Copyright (c) 2017 Hive.js
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/steemit/steem-js/blob/master/LICENSE)
[![Steem.js channel on steemit.chat](https://img.shields.io/badge/chat-steemit.chat-1c56a4.svg)](https://steemit.chat/channel/steemjs)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.syncad.com/hive/hive-js/blob/master/LICENSE)
# Steem.js
Steem.js the JavaScript API for Steem blockchain
# Hive.js
Hive.js the Official JavaScript API for Hive blockchain
# Documentation
- [Install](https://github.com/steemit/steem-js/tree/master/doc#install)
- [Browser](https://github.com/steemit/steem-js/tree/master/doc#browser)
- [Config](https://github.com/steemit/steem-js/tree/master/doc#config)
- [Database API](https://github.com/steemit/steem-js/tree/master/doc#api)
- [Subscriptions](https://github.com/steemit/steem-js/tree/master/doc#subscriptions)
- [Tags](https://github.com/steemit/steem-js/tree/master/doc#tags)
- [Blocks and transactions](https://github.com/steemit/steem-js/tree/master/doc#blocks-and-transactions)
- [Globals](https://github.com/steemit/steem-js/tree/master/doc#globals)
- [Keys](https://github.com/steemit/steem-js/tree/master/doc#keys)
- [Accounts](https://github.com/steemit/steem-js/tree/master/doc#accounts)
- [Market](https://github.com/steemit/steem-js/tree/master/doc#market)
- [Authority / validation](https://github.com/steemit/steem-js/tree/master/doc#authority--validation)
- [Votes](https://github.com/steemit/steem-js/tree/master/doc#votes)
- [Content](https://github.com/steemit/steem-js/tree/master/doc#content)
- [Witnesses](https://github.com/steemit/steem-js/tree/master/doc#witnesses)
- [Login API](https://github.com/steemit/steem-js/tree/master/doc#login)
- [Follow API](https://github.com/steemit/steem-js/tree/master/doc#follow-api)
- [Broadcast API](https://github.com/steemit/steem-js/tree/master/doc#broadcast-api)
- [Broadcast](https://github.com/steemit/steem-js/tree/master/doc#broadcast)
- [Auth](https://github.com/steemit/steem-js/tree/master/doc#auth)
- [Install](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#install)
- [Browser](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#browser)
- [Config](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#config)
- [Database API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#api)
- [Subscriptions](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#subscriptions)
- [Tags](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#tags)
- [Blocks and transactions](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#blocks-and-transactions)
- [Globals](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#globals)
- [Keys](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#keys)
- [Accounts](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#accounts)
- [Market](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#market)
- [Authority / validation](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#authority--validation)
- [Votes](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#votes)
- [Content](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#content)
- [Witnesses](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#witnesses)
- [Login API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#login)
- [Follow API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#follow-api)
- [Broadcast API](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#broadcast-api)
- [Broadcast](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#broadcast)
- [Auth](https://gitlab.syncad.com/hive/hive-js/tree/master/doc#auth)
Here is full documentation:
https://github.com/steemit/steem-js/tree/master/doc
https://gitlab.syncad.com/hive/hive-js/tree/master/doc
## Browser
```html
<script src="./steem.min.js"></script>
<script src="./hive.min.js"></script>
<script>
steem.api.getAccounts(['ned', 'dan'], function(err, response){
hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, response){
console.log(err, response);
});
</script>
```
## CDN
https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js<br/>
https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js<br/>
```html
<script src="https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@hiveio/hive-js/dist/hive.min.js"></script>
```
## Webpack
[Please have a look at the webpack usage example.](https://github.com/steemit/steem-js/blob/master/examples/webpack-example)
[Please have a look at the webpack usage example.](https://gitlab.syncad.com/hive/hive-js/blob/master/examples/webpack-example)
## Server
## Install
```
$ npm install steem --save
$ npm install @hiveio/hive-js --save
```
## RPC Servers
https://api.steemit.com By Default<br/>
https://node.steem.ws<br/>
https://this.piston.rocks<br/>
https://api.hive.blog By Default<br/>
https://anyx.io<br/>
https://api.openhive.network<br/>
https://api.hivekings.com<br/>
https://api.pharesim.me<br/>
https://hived.privex.io<br/>
https://rpc.ausbit.dev<br/>
https://rpc.esteem.app<br/>
<sub>[List of Hive nodes](https://hivekings.com/nodes)</sub><br/>
## Examples
### Broadcast Vote
```js
var steem = require('steem');
var hive = require('@hiveio/hive-js');
var wif = steem.auth.toWif(username, password, 'posting');
steem.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) {
var wif = hive.auth.toWif(username, password, 'posting');
hive.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) {
console.log(err, result);
});
```
### Get Accounts
```js
steem.api.getAccounts(['ned', 'dan'], function(err, result) {
hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, result) {
console.log(err, result);
});
```
### Get State
```js
steem.api.getState('/trends/funny', function(err, result) {
hive.api.getState('/trends/funny', function(err, result) {
console.log(err, result);
});
```
### Reputation Formatter
```js
var reputation = steem.formatter.reputation(user.reputation);
var reputation = hive.formatter.reputation(user.reputation);
console.log(reputation);
```
### Steem Testnet
Steem-js requires some configuration to work on the public Steem testnet.
### Hive Testnet
Hive-js requires some configuration to work on the public Hive testnet.
You need to set two Steem API options, `address_prefix` and `chain_id`.
You need to set two Hive API options, `address_prefix` and `chain_id`.
```js
steem.api.setOptions({
hive.api.setOptions({
address_prefix: 'TST',
chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32',
useTestNet: true,
......@@ -107,7 +112,7 @@ steem.api.setOptions({
The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements.
## Contributions
Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them. If you would like to contribute, but don't know what to work on, check the issues list or on Steemit Chat channel #steemjs https://steemit.chat/channel/steemjs.
Patches are welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them.
## Issues
When you find issues, please report them!
......
......@@ -25,40 +25,41 @@
# Install
```
$ npm install steem --save
$ npm install @hiveio/hive-js --save
```
# Browser
```html
<script src="./steem.min.js"></script>
<script src="./hive.min.js"></script>
<script>
steem.api.getAccounts(['ned', 'dan'], function(err, response){
hive.api.getAccounts(['mahdiyari', 'hiveio'], function(err, response){
console.log(err, response);
});
</script>
```
## Config
Default config should work with steem. however you can change it to work with golos
Default config should work with Hive. However you can change default config.
as
```js
steem.api.setOptions({ url: 'wss://ws.golos.io' }); // assuming websocket is work at ws.golos.io
steem.config.set('address_prefix','GLS');
steem.config.set('chain_id','782a3039b478c839e4cb0c941ff4eaeb7df40bdd68bd441afd444b9da763de12');
hive.api.setOptions({ url: 'https://anyx.io' });
hive.config.set('address_prefix','STM');
hive.config.set('chain_id','0000000000000000000000000000000000000000000000000000000000000000');
hive.config.set('alternative_api_endpoints', ['https://api.hive.blog', 'https://anyx.io']);
```
### set
```
steem.config.set('address_prefix','STM');
hive.config.set('address_prefix','STM');
```
### get
```
steem.config.get('chain_id');
hive.config.get('chain_id');
```
## JSON-RPC
Here is how to activate JSON-RPC transport:
```js
steem.api.setOptions({ url: 'https://api.steemit.com' });
hive.api.setOptions({ url: 'https://api.hive.blog' });
```
# API
......@@ -67,25 +68,25 @@ steem.api.setOptions({ url: 'https://api.steemit.com' });
### Set Subscribe Callback
```
steem.api.setSubscribeCallback(callback, clearFilter, function(err, result) {
hive.api.setSubscribeCallback(callback, clearFilter, function(err, result) {
console.log(err, result);
});
```
### Set Pending Transaction Callback
```
steem.api.setPendingTransactionCallback(cb, function(err, result) {
hive.api.setPendingTransactionCallback(cb, function(err, result) {
console.log(err, result);
});
```
### Set Block Applied Callback
```
steem.api.setBlockAppliedCallback(cb, function(err, result) {
hive.api.setBlockAppliedCallback(cb, function(err, result) {
console.log(err, result);
});
```
### Cancel All Subscriptions
```
steem.api.cancelAllSubscriptions(function(err, result) {
hive.api.cancelAllSubscriptions(function(err, result) {
console.log(err, result);
});
```
......@@ -94,73 +95,73 @@ steem.api.cancelAllSubscriptions(function(err, result) {
### Get Trending Tags
```
steem.api.getTrendingTags(afterTag, limit, function(err, result) {
hive.api.getTrendingTags(afterTag, limit, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Trending
```
steem.api.getDiscussionsByTrending(query, function(err, result) {
hive.api.getDiscussionsByTrending(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Created
```
steem.api.getDiscussionsByCreated(query, function(err, result) {
hive.api.getDiscussionsByCreated(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Active
```
steem.api.getDiscussionsByActive(query, function(err, result) {
hive.api.getDiscussionsByActive(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Cashout
```
steem.api.getDiscussionsByCashout(query, function(err, result) {
hive.api.getDiscussionsByCashout(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Payout
```
steem.api.getDiscussionsByPayout(query, function(err, result) {
hive.api.getDiscussionsByPayout(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Votes
```
steem.api.getDiscussionsByVotes(query, function(err, result) {
hive.api.getDiscussionsByVotes(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Children
```
steem.api.getDiscussionsByChildren(query, function(err, result) {
hive.api.getDiscussionsByChildren(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Hot
```
steem.api.getDiscussionsByHot(query, function(err, result) {
hive.api.getDiscussionsByHot(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Feed
```
steem.api.getDiscussionsByFeed(query, function(err, result) {
hive.api.getDiscussionsByFeed(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Blog
```
steem.api.getDiscussionsByBlog(query, function(err, result) {
hive.api.getDiscussionsByBlog(query, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Comments
```
steem.api.getDiscussionsByComments(query, function(err, result) {
hive.api.getDiscussionsByComments(query, function(err, result) {
console.log(err, result);
});
```
......@@ -169,43 +170,43 @@ steem.api.getDiscussionsByComments(query, function(err, result) {
### Get Block Header
```
steem.api.getBlockHeader(blockNum, function(err, result) {
hive.api.getBlockHeader(blockNum, function(err, result) {
console.log(err, result);
});
```
### Get Block
```
steem.api.getBlock(blockNum, function(err, result) {
hive.api.getBlock(blockNum, function(err, result) {
console.log(err, result);
});
```
### Get State
```
steem.api.getState(path, function(err, result) {
hive.api.getState(path, function(err, result) {
console.log(err, result);
});
```
### Get Trending Categories
```
steem.api.getTrendingCategories(after, limit, function(err, result) {
hive.api.getTrendingCategories(after, limit, function(err, result) {
console.log(err, result);
});
```
### Get Best Categories
```
steem.api.getBestCategories(after, limit, function(err, result) {
hive.api.getBestCategories(after, limit, function(err, result) {
console.log(err, result);
});
```
### Get Active Categories
```
steem.api.getActiveCategories(after, limit, function(err, result) {
hive.api.getActiveCategories(after, limit, function(err, result) {
console.log(err, result);
});
```
### Get Recent Categories
```
steem.api.getRecentCategories(after, limit, function(err, result) {
hive.api.getRecentCategories(after, limit, function(err, result) {
console.log(err, result);
});
```
......@@ -214,55 +215,55 @@ steem.api.getRecentCategories(after, limit, function(err, result) {
### Get Config
```
steem.api.getConfig(function(err, result) {
hive.api.getConfig(function(err, result) {
console.log(err, result);
});
```
### Get Dynamic Global Properties
```
steem.api.getDynamicGlobalProperties(function(err, result) {
hive.api.getDynamicGlobalProperties(function(err, result) {
console.log(err, result);
});
```
### Get Chain Properties
```
steem.api.getChainProperties(function(err, result) {
hive.api.getChainProperties(function(err, result) {
console.log(err, result);
});
```
### Get Feed History
```
steem.api.getFeedHistory(function(err, result) {
hive.api.getFeedHistory(function(err, result) {
console.log(err, result);
});
```
### Get Current Median History Price
```
steem.api.getCurrentMedianHistoryPrice(function(err, result) {
hive.api.getCurrentMedianHistoryPrice(function(err, result) {
console.log(err, result);
});
```
### Get Hardfork Version
```
steem.api.getHardforkVersion(function(err, result) {
hive.api.getHardforkVersion(function(err, result) {
console.log(err, result);
});
```
### Get Next Scheduled Hardfork
```
steem.api.getNextScheduledHardfork(function(err, result) {
hive.api.getNextScheduledHardfork(function(err, result) {
console.log(err, result);
});
```
### Get Reward Fund
```
steem.api.getRewardFund(name, function(err, result) {
hive.api.getRewardFund(name, function(err, result) {
console.log(err, result);
});
```
### Get Vesting Delegations
```
steem.api.getVestingDelegations(account, from, limit, function(err, result) {
hive.api.getVestingDelegations(account, from, limit, function(err, result) {
console.log(err, result);
});
```
......@@ -271,7 +272,7 @@ steem.api.getVestingDelegations(account, from, limit, function(err, result) {
### Get Key References
```
steem.api.getKeyReferences(key, function(err, result) {
hive.api.getKeyReferences(key, function(err, result) {
console.log(err, result);
});
```
......@@ -280,55 +281,55 @@ steem.api.getKeyReferences(key, function(err, result) {
### Get Accounts
```
steem.api.getAccounts(names, function(err, result) {
hive.api.getAccounts(names, function(err, result) {
console.log(err, result);
});
```
### Get Account References
```
steem.api.getAccountReferences(accountId, function(err, result) {
hive.api.getAccountReferences(accountId, function(err, result) {
console.log(err, result);
});
```
### Lookup Account Names
```
steem.api.lookupAccountNames(accountNames, function(err, result) {
hive.api.lookupAccountNames(accountNames, function(err, result) {
console.log(err, result);
});
```
### Lookup Accounts
```
steem.api.lookupAccounts(lowerBoundName, limit, function(err, result) {
hive.api.lookupAccounts(lowerBoundName, limit, function(err, result) {
console.log(err, result);
});
```
### Get Account Count
```
steem.api.getAccountCount(function(err, result) {
hive.api.getAccountCount(function(err, result) {
console.log(err, result);
});
```
### Get Conversion Requests
```
steem.api.getConversionRequests(accountName, function(err, result) {
hive.api.getConversionRequests(accountName, function(err, result) {
console.log(err, result);
});
```
### Get Account History
```
steem.api.getAccountHistory(account, from, limit, function(err, result) {
hive.api.getAccountHistory(account, from, limit, function(err, result) {
console.log(err, result);
});
```
### Get Owner History
```
steem.api.getOwnerHistory(account, function(err, result) {
hive.api.getOwnerHistory(account, function(err, result) {
console.log(err, result);
});
```
### Get Recovery Request
```
steem.api.getRecoveryRequest(account, function(err, result) {
hive.api.getRecoveryRequest(account, function(err, result) {
console.log(err, result);
});
```
......@@ -337,19 +338,19 @@ steem.api.getRecoveryRequest(account, function(err, result) {
### Get Order Book
```
steem.api.getOrderBook(limit, function(err, result) {
hive.api.getOrderBook(limit, function(err, result) {
console.log(err, result);
});
```
### Get Open Orders
```
steem.api.getOpenOrders(owner, function(err, result) {
hive.api.getOpenOrders(owner, function(err, result) {
console.log(err, result);
});
```
### Get Liquidity Queue
```
steem.api.getLiquidityQueue(startAccount, limit, function(err, result) {
hive.api.getLiquidityQueue(startAccount, limit, function(err, result) {
console.log(err, result);
});
```
......@@ -358,37 +359,37 @@ steem.api.getLiquidityQueue(startAccount, limit, function(err, result) {
### Get Transaction Hex
```
steem.api.getTransactionHex(trx, function(err, result) {
hive.api.getTransactionHex(trx, function(err, result) {
console.log(err, result);
});
```
### Get Transaction
```
steem.api.getTransaction(trxId, function(err, result) {
hive.api.getTransaction(trxId, function(err, result) {
console.log(err, result);
});
```
### Get Required Signatures
```
steem.api.getRequiredSignatures(trx, availableKeys, function(err, result) {
hive.api.getRequiredSignatures(trx, availableKeys, function(err, result) {
console.log(err, result);
});
```
### Get Potential Signatures
```
steem.api.getPotentialSignatures(trx, function(err, result) {
hive.api.getPotentialSignatures(trx, function(err, result) {
console.log(err, result);
});
```
### Verify Authority
```
steem.api.verifyAuthority(trx, function(err, result) {
hive.api.verifyAuthority(trx, function(err, result) {
console.log(err, result);
});
```
### Verify Account Authority
```
steem.api.verifyAccountAuthority(nameOrId, signers, function(err, result) {
hive.api.verifyAccountAuthority(nameOrId, signers, function(err, result) {
console.log(err, result);
});
```
......@@ -397,13 +398,13 @@ steem.api.verifyAccountAuthority(nameOrId, signers, function(err, result) {
### Get Active Votes
```
steem.api.getActiveVotes(author, permlink, function(err, result) {
hive.api.getActiveVotes(author, permlink, function(err, result) {
console.log(err, result);
});
```
### Get Account Votes
```
steem.api.getAccountVotes(voter, function(err, result) {
hive.api.getAccountVotes(voter, function(err, result) {
console.log(err, result);
});
```
......@@ -413,25 +414,25 @@ steem.api.getAccountVotes(voter, function(err, result) {
### Get Content
```
steem.api.getContent(author, permlink, function(err, result) {
hive.api.getContent(author, permlink, function(err, result) {
console.log(err, result);
});
```
### Get Content Replies
```
steem.api.getContentReplies(author, permlink, function(err, result) {
hive.api.getContentReplies(author, permlink, function(err, result) {
console.log(err, result);
});
```
### Get Discussions By Author Before Date
```
steem.api.getDiscussionsByAuthorBeforeDate(author, startPermlink, beforeDate, limit, function(err, result) {
hive.api.getDiscussionsByAuthorBeforeDate(author, startPermlink, beforeDate, limit, function(err, result) {
console.log(err, result);
});
```
### Get Replies By Last Update
```
steem.api.getRepliesByLastUpdate(startAuthor, startPermlink, limit, function(err, result) {
hive.api.getRepliesByLastUpdate(startAuthor, startPermlink, limit, function(err, result) {
console.log(err, result);
});
```
......@@ -441,43 +442,43 @@ steem.api.getRepliesByLastUpdate(startAuthor, startPermlink, limit, function(err
### Get Witnesses
```
steem.api.getWitnesses(witnessIds, function(err, result) {