iscn-js
Javascript SDK for ISCN actions.

Repository Link

Install

1
npm i -S @cosmjs/stargate @likecoin/iscn-js
Copied!

Usage

Please refer to *.spec.ts test cases for more example
Query
1
import { ISCNQueryClient } from '@likecoin/iscn-js';
2
const client = new ISCNQueryClient();
3
4
// optional custom rpc
5
// await client.connect('https://mainnet-node.like.co/rpc/')
6
7
// Query ISCN by ID
8
const res = await client.queryRecordsById('iscn://likecoin-chain/dLbKMa8EVO9RF4UmoWKk2ocUq7IsxMcnQL1_Ps5Vg80/1');
9
10
// Query ISCN by owner
11
const res = await client.queryRecordsByOwner('cosmos1sf2sc6t37xhd3m0dcaq6h5dz22mtru2ugdwp0v');
Copied!
Signing
1
import { ISCNQueryClient, ISCNSigningClient } from '@likecoin/iscn-js';
2
import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing';
3
import { assertIsBroadcastTxSuccess, SigningStargateClient, StargateClient } from '@cosmjs/stargate';
4
5
const mnemonic = 'surround miss nominee dream gap cross assault thank captain prosper drop duty group candy wealth weather scale put';
6
const signer = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic);
7
const [wallet] = await signer.getAccounts();
8
9
const client = new ISCNQueryClient();
10
const signingClient = new ISCNSigningClient();
11
await signingClient.connectWithSigner('https://mainnet-node.like.co/rpc/', wallet);
12
13
const res = await signingClient.createISCNRecord(wallet.address, {
14
'contentFingerprints': [
15
'hash://sha256/9564b85669d5e96ac969dd0161b8475bbced9e5999c6ec598da718a3045d6f2e'
16
],
17
'stakeholders': [
18
{
19
'entity': {
20
'@id': 'did:cosmos:5sy29r37gfxvxz21rh4r0ktpuc46pzjrmz29g45',
21
'name': 'Chung Wu'
22
},
23
'rewardProportion': 95,
24
'contributionType': 'http://schema.org/author'
25
}
26
],
27
'type': 'Article',
28
'name': '使用矩陣計算遞歸關係式',
29
'usageInfo': 'https://creativecommons.org/licenses/by/4.0',
30
'keywords': ['matrix', 'recursion'],
31
});
32
33
const iscnID = await client.queryISCNIdsByTx(res.transactionHash);
Copied!
Export as PDF
Copy link