Continuing our posts for developers, we’d like to introduce you to some tools available to JavaScript developers: our JavaScript SDK and command line tool.
Installing the SDK on Your Local Machine
To install the SDK as a Node.js package on your local machine, clone the SDK from here: https://github.com/aeternity/aepp-sdk-js, cd into the SDK folder on your machine and execute:
npm install
or
yarn i @aeternity/aepp-sdk@next
Congratulations — you have installed our JS SDK on your local machine!
Making an Account Via the Command Line Client
Once you have the SDK running, you will probably want to make an account (a key pair) and fill up your account with some Testnet AE tokens from the Token Faucet. You can create the wallet using our command line tool, like so:
./bin/aecli.js wallet mywallet create
In the example above, “mywallet” is the name of your account.
Getting Tokens
You will need the address of your account to receive Testnet AE tokens. To find out the address of your account, type in the following:
./bin/aecli.js wallet mywallet address
After you enter your password, your address will be displayed on the screen.
To receive tokens, go to https://faucet.aepps.com, paste your address in the input field, and click “Top up!”. Once the tokens have been added to your account, you can check your account balance using this command:
./bin/aecli.js wallet mywallet balance
You can now see the available token balance on your screen!
Incorporating the SDK Into Your Project
You can incorporate the JS SDK into your project in one out of three ways: via ES modules, as a Node.js bundle, as well as a browser bundle. You can learn more about the three options here.
Using the SDK
Promises
The JS SDK is written in ES6 (and transpiled by Babel). Most methods in the JS SDK return Promises. Promises are a way to execute the results of asynchronous events, in a synchronous order. We recommend that dealing with subsequent actions is done via then chaining with a final catch callback.
Code Examples
We have written walkthrough for code examples for: the contracts, wallet, and crypto modules here. For beginners, the most useful example is contracts.
The Future
Up to now, we’ve been working on giving the best interface to æternity that we can. We’re almost at the point of supporting all of the features of the blockchain, so now we’re going to work on improving the SDK. Ideas that we’re planning for the future include: setting the number of elapsed blocks to wait before returning, to permit different levels of certainty that one’s not on a fork, with different levels of certainty for different situations, integration with popular IDEs, better examples and more. If you have feedback on what we should do to improve the SDKs, please email us at aepp-dev@aeternity.com, to let us know.
æternity Tech Updates on Twitter
We have created a new twitter account focused specifically on tech updates from our blockchain and æpps teams. To read all about our technology first follow:
Interested in æternity? Get in touch:
GitHub | Forum | Reddit | Telegram | Twitter | Facebook | Mail
No Comments.