alaexplorerjs4
General purpose library for the ALA blockchain.
Usage (read-only)
Ala = // Or Ala = require('./src') // API, note: testnet uses alad at localhost (until there is a testnet)ala = Ala // All API methods print help when called with no-arguments.ala // Next, your going to need alad running on localhost:8888 // If a callback is not provided, a Promise is returnedala // Parameters can be sequential or an objectala // Callbacks are similar {err ? console : console}alaala // Provide an empty object or a callback if an API call has no argumentsala
API methods and documentation are generated from:
Configuration
Ala = // Or Ala = require('./src') config = httpEndpoint: 'http://127.0.0.1:8888' expireInSeconds: 60 broadcast: true debug: false sign: true ala = Ala
Options
Options may be provided immediately after parameters.
Example: ala.transfer(params, options)
options = broadcast: true sign: true scope: null authorization: null
-
scope
{array<string>|string}
- account name or names that may undergo a change in state.- If missing default scopes will be calculated.
- If provided additional scopes will not be added.
- Sorting is always performed.
-
authorization
{array<auth>|auth}
- identifies the signing account and permission typically in a multi-sig configuration. Authorization may be a string formatted asaccount@permission
or anobject<{account, permission}>
.- If missing default authorizations will be calculated.
- If provided additional authorizations will not be added.
- Sorting is always performed (by account name).
Usage (read/write)
Ala = // Or Ala = require('./src') ala = Ala // Run with no arguments to print usage.ala // Usage with options (options are always optional)options = broadcast: falseala // Object or ordered args may be used.ala // A broadcast boolean may be provided as a shortcut for {broadcast: false}ala
Read-write API methods and documentation are generated from this schema.
For more advanced signing, see keyProvider
in the unit test.
Shorthand
Shorthand is available for some types such as Asset and Authority.
For example:
- deposit:
'1 ALA'
is shorthand for1.0000 ALA
- owner:
'ALA6MRy..'
is shorthand for{threshold: 1, keys: [key: 'ALA6MRy..', weight: 1]}
- recovery:
inita
orinita@active
is shorthand{{threshold: 1, accounts: [..account: inita, permission: active, weight: 1]}}
inita@other
would replace the permissionactive
withother
Ala = // Or Ala = require('./src') initaPrivate = '5HzzqBmg4DeneRqNRznPiBubRDGEPdcVjGZCTMGjGJWJubKm2Pe'initaPublic = 'ALA8dM36QedcUfPTNF7maThtRqHP5xvCqMsYiHUz1Rz7sPfhvCYuo'keyProvider = initaPrivate ala = Ala ala
Contract
Ala = // Or Ala = require('./src')let ecc = Alamodules initaPrivate = '5HzzqBmg4DeneRqNRznPiBubRDGEPdcVjGZCTMGjGJWJubKm2Pe' // New deterministic key for the currency account. Only use a simple// seedPrivate in production if you want to give away money.currencyPrivate = ecccurrencyPublic = ecc keyProvider = initaPrivate currencyPrivate ala = Ala ala contractDir = `/alaio/ala/build/contracts/currency`wast = fsabi = fs // Publish contract to the blockchainala // ala.contract(code<string>, [options], [callback])ala
Atomic Operations
Blockchain level atomic operations. All will pass or fail.
Ala = // Or Ala = require('./src') keyProvider = '5HzzqBmg4DeneRqNRznPiBubRDGEPdcVjGZCTMGjGJWJubKm2Pe' Alamodulesecc testnet = Ala // if either transfer fails, both will fail (1 transaction, 2 messages)testnet // transaction on a single contracttestnet // mix contracts in the same transactiontestnet // contract lookups then transactionstestnet // Note, the contract method does not take an array. Just use Await or yield// if multiple contracts are needed outside of a transaction.
Usage (manual)
A manual transaction provides for more flexibility.
Ala = // Or Ala = require('./src') ala = Ala ala
Development
From time-to-time the alaexplorerjs4 and alad binary format will change between releases
so you may need to start alad
with the --skip-transaction-signatures
parameter
to get your transactions to pass.
Note, package.json
has a "main" pointing to ./lib
. The ./lib
folder is for
es2015 code built in a separate step. If your changing and testing code,
import from ./src
instead.
Ala =
Use Node v8+ to package-lock.json
.
Related Libraries
These libraries are exported from alaexplorerjs4
or may be used separately.
var api ecc json Fcbuffer = Alamodules
About
-
alaexplorerjs4-api-v2.0.1 [Github, NPM]
- Remote API to an ALA blockchain node (alad)
- Use this library directly if you need read-only access to the blockchain (don't need to sign transactions).
-
alaexplorerjs4-ecc-v1.6.1 [Github, NPM]
- Private Key, Public Key, Signature, AES, Encryption / Decryption
- Validate public or private keys
- Encrypt or decrypt with ALA compatible checksums
- Calculate a shared secret
-
alaexplorerjs4-json-v2.0.2 [Github, NPM]
- Blockchain definitions (api method names, blockchain operations, etc)
- Maybe used by any language that can parse json
- Kept up-to-date
-
- Binary serialization used by the blockchain
- Clients sign the binary form of the transaction
- Essential so the client knows what it is signing
Browser
git clone https://github.com/ALADIN-Network/alaexplorerjs4.gitcd alaexplorerjs4npm installnpm run build# builds: ./dist/ala.js
Environment
Node 6+ and browser (browserify, webpack, etc)
React Native should work, create an issue if you find a bug.