beowulf-js
beowulf-js is the official Beowulf library for Javascript.
Full Documentation
Main Functions Supported
- CHAIN
- TRANSACTION
- broadcast_transaction
- create transaction transfer
- create account
Requirements
- npm minimum version 6.9.0
Install
// MainNet
npm i beowulf-js
// TestNet
npm i beowulf-js-testnet
Configuration
const beowulfjs = require('beowulf-js');
let url = beowulfjs.config.get('uri');
beowulfjs.api.setOptions({ url: url, useAppbaseApi: true });
Example Usage
Get a block
let blockNum = 232967;
beowulfjs.api.getBlock(blockNum, function(err, result) {
console.log(err, result);
});
Get Transaction
let trxId = '60207c8e17f47bf2790c927701792d95d42e3f46';
beowulfjs.api.getTransaction(trxId, function(err, result) {
console.log(err, result);
});
Generate a wallet
API
let wallet = beowulfjs.wallet.generateWallet();
Response Example
{
"owner": "5JY3sGqkfoN7U6kee9HibnG6etQgLNCMqjhPqsVDRXRjGwFNKeA",
"ownerPubkey": "BEO7GXMArUCaxq1kPNP4JkcnshVDyfpVTfEwL8e8FVAN6BgpU8Y1k"
}
Submit Wallet to Blockchain
API
beowulfjs.wallet.submitWallet({
ownerPubkey,
account,
creator,
creatorWif,
fee
}, (err, result) => {
})
Params:
ownerPubkey: string
account: string
fee: string
creator: string
creatorWif: string
let ownerPubkey = 'BEO7GXMArUCaxq1kPNP4JkcnshVDyfpVTfEwL8e8FVAN6BgpU8Y1k';
let account = 'newwallet';
let creator = 'creatorwallet';
let creatorWif = '5Kxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
let fee = '0.00100 W';
beowulfjs.wallet.submitWallet({
ownerPubkey,
account,
creator,
creatorWif,
fee
}, (err, result) => {
})
Submit Transaction
API
beowulfjs.broadcast.transfer(wif, from, to, amount, fee, memo, (err, result) => {
console.log(err, result);
});
Params:
from: string
wif: string
to: string
amount: string
memo: string
fee: string
let from = 'examplewallet';
let wif = '5Jxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
let to = 'examplewallet2';
let amount = '4.00000 BWF';
let memo = 'example';
let fee = '0.00001 W';
beowulfjs.broadcast.transfer(wif, from, to, amount, fee, memo, (err, result) => {
console.log(err, result);
});