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
Roy Sirui Yang edited this page Apr 28, 2020
·
14 revisions
You can create a signed and encoded doughnut:
const Doughnut = require('plug-doughnut').Doughnut;
const domain = 'awesome_node';
const doughnut = Doughnut
.new(issuer, holder, expiry, not_before)
.add_domain(domain, 0x00)
.sign(issuer_secrect_key)
.encode();
You can add the encoded doughnut to the extrinsic call.
This example creates a normal balance transfer with the encoded doughnut added in the option
parameter.
// Create the API and wait until ready
const provider = new WsProvider("ws://localhost:9944");
const types = PlugRuntimeTypes.default;
const api = await ApiPromise.create({ provider, types });
// Send transfer extrinsic with doughnut
const options = { doughnut: doughnut.encode() };
const txHash = await api.tx.balances
.transfer(keyring.bob.address, "1_500_000_000")
.signAndSend(keyring.alice, options);
Getting Started
PL^G Component Guides
- Attestation
- Doughnut
- Generic Assets (coming soon)
Advanced Topics
External Links