The Javascript SDK wraps the æternity API explosed by Node's Swagger file. It aims to abstract the API, while still providing low-level access to it's endpoints, when necessary.
It uses the following Javascript technologies and principles:
- stampit provides composable Factories based on the Stamp Specification. This is how aepp-sdk approached the composition over inheritance principle.
- JavaScript the Good Parts (because Crockford is always right)
- ES6 modules, using
export
andimport
- Promises using ES7 async/await syntax, where applicable
- Functional Programming using Ramda
- Statelessness wherever possible
- webpack 4 and the Babel loader
- Strictly enforced StandardJS
- Loose coupling of modules to enable tree-shaking
- Convention over configuration
- "Easy things should be easy, and hard things should be possible." source -- Larry Wall
- Support for
- module access, enabling tree-shaking
- direct use in node scripts through bundling
- direct use in browser
<script>
tags through bundling - bundling through webpack
aepp-sdk is transpiled to EcmaScript 5 through WebPack, using Babel and is expected to work in any sufficiently new version of Node.js (>= 8.11
) or modern web browser.
- Clone the application
- Make sure your editor/IDE can read and use the
.editorconfig
file - Start hacking (and dont forget to add test for whatever you'll be building).
Apart from documenting features and code, there is also documentation automatically generated using jsdoc for documenting JS files (later transformed in to .md
files (to have them readable in platforms like GitHub) and docco for documenting examples and code partials.
#generate documentation with docco + jsdoc (and markdownify jsdoc)
npm run docs:docco && npm run docs:api
aepp-sdk is built using pnpm. In order to build a development version, launch the build:dev
command.
pnpm install
pnpm run build:dev
To test, launch the test
command. This will run mocha's tests locally.
pnpm run test
This repository also includes a docker-compose file, to allow you to run your own aeternity node locally. If you want to do so, from the root of the project:
- Create a docker-compose.override.yml file with this content:
version: "3"
services:
node:
ports:
- 3013:3013
- 3113:3113
- 3014:3014
- 3001:3001
- Run
docker-compose up node
- Congrats! you're now running your own aeternity node locally.
You can also "compose" your own flavor by mixing 2 or more flavors likes so:
import Wallet from '@aeternity/aepp-sdk/es/ae/wallet.js'
import Contract from '@aeternity/aepp-sdk/es/ae/contract.js'
import MemoryAccount from '@aeternity/aepp-sdk/es/account/memory.js'
// make a "mixed flavor" containing Wallet and Contracts flavors
Wallet.compose(Contract)({
url: 'https://sdk-testnet.aepps.com',
internalUrl: 'https://sdk-testnet.aepps.com',
accounts: [MemoryAccount({keypair: {secretKey: account.priv, publicKey: account.pub}})],
address: account.pub,
onTx: true, // or a function to Guard the Rpc client
onChain: true, // or a function to Guard the Rpc client
onAccount: true, // or a function to Guard the Rpc client
networkId: 'ae_uat'
}).then(ae => {
// ae is your initialised client now! :)
// ...
The WebPack compilation provides two different build artifacts in dist/
, one
for Node.js and one for browsers. When referencing aepp-sdk through any modern
build tooling, it should pick the right one automatically through the entry
points defined in package.json
.
In order to add a local development version of aepp-sdk to a project, npm link
1 can be used.
If you're interested in getting sample code/guide, you can check out the Guides