This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Javascript API Reference
Hoani Bryson edited this page Apr 28, 2020
·
14 revisions
The Pl^g blockchain features a rich API for developing your D'App.
The easiest way to get started is to follow our API getting started guide
For a detailed reference on how the API works, see the Polkadot API reference
The full Blockchain API is accessed by creating an API object:
const provider = new WsProvider('ws://localhost:9944');
const api = await ApiPromise.create({
provider,
types: PlugRuntimeTypes,
});
The object needs:
- The websocket
provider
(for testing locally, the default isws://localhost:9944
) - Specific runtime types used by your application
- As new runtime modules are added to your Pl^g blockchain, you may need to add more types here.
The imports required to build the API object are:
import {ApiPromise, WsProvider} from '@polkadot/api';
import PlugRuntimeTypes from '@plugnet/plug-api-types';
One of the key features of Pl^g is delegated dispatch calls. This allows Bob
to give Alice
permissions using Bob's
account.
When sending an extrinsic, doughnuts are attached when signing:
const txHash = await api.tx.balances
.transfer(keyring.charlie.address, "1_500_000_000")
.signAndSend(keyring.alice, {doughnut: encoded_doughnut});
For a more detailed guide see using Doughnut with Pl^g
Getting Started
PL^G Component Guides
- Attestation
- Doughnut
- Generic Assets (coming soon)
Advanced Topics
External Links