aelf-sdk.js - AELF JavaScript API

Introduction
This is the AELF JavaScript API which connects to the Generic JSON RPC spec.
You need to run a local or remote AELF node to use this library.
Please read the ./docs for more.
Get the demos in ./demos
Installaction
Node
npm install aelf-sdk
Yarn
yarn add aelf-sdk
Usage
Five modules.
Aelf, Aelf.wallet, Aelf.pbjs, Aelf.pbUtils, Aelf.version
basic
import Aelf from 'aelf-sdk';
const aelf = new Aelf(
new Aelf.providers.HttpProvider(
host,
timeout,
user,
password,
[{
name: 'x-csrf-token',
value: document.cookie.match(/csrfToken=[^;]*/)[0].replace('csrfToken=', '')
}]
)
);
init contract and call methods
aelf.chain.contractAtAsync(contractAddress, wallet, (err, result) => {
const contractoktMethods = result;
contractoktMethods.Transfer({
symbol: 'ELF',
to: '58h3RwTfaE8RDpRNMAMiMv8jUjanCeYHBzKuQfHbrfSFTCn',
amount: '1000'
}, (err, result) => {
});
contractMethods.GetBalance.call({
symbol: 'ELF',
owner: '58h3RwTfaE8RDpRNMAMiMv8jUjanCeYHBzKuQfHbrfSFTCn'
}, (err, result) => {
});
});
Additionally you can set a provider using aelf.setProvider()
import Aelf from 'aelf-sdk';
const aelf = new Aelf(new Aelf.providers.HttpProvider('https://127.0.0.1:8000/chain'));
aelf.setProvider(new Aelf.providers.HttpProvider('https://127.0.0.1:8010/chain'));
wallet
base on bip39.
import Aelf from 'aelf-sdk';
Aelf.wallet.createNewWallet();
pbjs
almost the same as protobufjs
Sometimes we have to deal with some protobuf data.
pbUtils
Some basic format methods of aelf.
For more information, please see the code in ./lib/aelf/proto.js. It is simple and easy to understand.
getRepForAddress
getAddressFromRep
getAddressObjectFromRep
getRepForHash
getHashFromHex
getHashObjectFromHex
getTransaction
getMsigTransaction
getAuthorization
getReviewer
encodeTransaction
getProposal
encodeProposal
getApproval
encodeApproval
getSideChainInfo
getBalance
encodeSideChainInfo
Transaction
Hash
Address
Authorization
Proposal
ProposalStatus
SideChainInfo
SideChainStatus
ResourceTypeBalancePair
version
import Aelf from 'aelf-sdk';
Aelf.version
Contributing
-
All contributions have to go into the dev-2.0 branch
-
Please follow the code style of the other files, we use 4 spaces as tabs.
Requirements
Support

Somthing more
pbjs
how to use pbjs convert proto to json
node ./node_modules/protobufjs/bin/pbjs -t json ./lib/aelf/proto/abi.proto > ./lib/aelf/proto/abi.proto.json
About Version
https://semver.org/