Interaction with the blockchain happens by broadcasting transactions to the nodes. A transaction is usually built and signed locally and then broadcast. It is considered accepted after being included in a block and finalized after its block becomes irreversible. A transaction can contain several operations (tranfer, limit order, etc..), this allows to execute several actions on the blockchain in an atomic fashion (one fails all fail) and without the need to sign each one separately (beneficial for performance). For this you may use the transaction builder.
The easiest way to install NodeJS is to use Node Version Manager.
To install nvm for Ubuntu or OSX, use following commands in terminal using a non-root user:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash
nvm install v10
nvm use v10
git clone -b master https://github.com/bitshares/btsdex.git
cd btsdex
npm install
The below example can be used to broadcast any transaction to the BitShares Blockchain using API node hence you can use any BitShares Public API node, you will just need to replace parameters under params and the operation name asset_update in below example with your desired transaction parameters and its operation name.
Use the below links to determine your desired operation name and needed parameters along with their required order:
bitshares-core available operation names
btsdex library parameters serialization and order
Create file transaction.js in main btsdex directory, copy paste the below example and read the notes next to hash:
const BitShares = require("btsdex");
BitShares.connect("wss://dex.iobanker.com/ws"); # replace wss://dex.iobanker.com/ws with API node if you want to use another BitShares API node
BitShares.subscribe('connected', startAfterConnected);
async function startAfterConnected() {
let acc = await new BitShares("username", "password"); # replace with your username and password
# Below are required parameters and structure for the example of operation *asset_update*; every different operation would required different parameters and structure
# Finding what data to use in these parameters would require understanding of how BitShares Blockchain works, for example *issuer* is referred to the ID *1.2.1787259* of owner account of an Asset, use telegram [BitShares Development](https://t.me/BitSharesDEV) group to ask about required parameters.
let params = {
fee: {amount: 0, asset_id: "1.3.0"},
"issuer":"1.2.1787259",
"asset_to_update":"1.3.5537",
"new_options": {
"max_supply": "1000000000000000",
"market_fee_percent": 0,
"max_market_fee": "0",
"min_market_fee": 0,
"issuer_permissions": 79,
"flags": 6,
"core_exchange_rate": {
"base": {"amount": 500000, "asset_id": "1.3.0"},
"quote": {"amount": 10000, "asset_id": "1.3.5537"}
},
"whitelist_authorities": [],
"blacklist_authorities": [],
"whitelist_markets": [],
"blacklist_markets": [],
"description": "{\"main\":\"Asset Info\",\"market\":\"Market info\"}",
"extensions": {"taker_fee_percent": 10}
}
}
let tx = acc.newTx();
tx.asset_update(params); # Replace asset_update with your desired operation name
await tx.broadcast();
console.log(tx);
}
Execute the script file using node:
node transaction.js