Specification

Contracts

Each coin follows a strict implementation contract. All of these contracts can be found at the following links.

Network Manifest

Each coin follows a strict implementation contract which can be incomplete for certain coins due to how they work or a lack of features. The missing or unsupported methods will throw exceptions and to avoid unwanted surprised we need a way of letting consumers of the SDK know that calling a certain method will lead to an exception.

Example

Let’s take the sdk-ark network manifest as an example. It contains some information like the name and ticker, but the important part is the featureFlags object. This object contains all supported services and methods.

1import { Networks } from "@ardenthq/sdk";
2 
3import { explorer, featureFlags, importMethods, transactions } from "./shared";
4 
5const network: Networks.NetworkManifest = {
6 id: "ark.mainnet",
7 type: "live",
8 name: "Mainnet",
9 coin: "ARK",
10 currency: {
11 ticker: "ARK",
12 symbol: "Ѧ",
13 decimals: 8,
14 },
15 constants: {
16 slip44: 111,
17 },
18 hosts: [
19 {
20 type: "full",
21 host: "https://ark-live.arkvault.io/api",
22 },
23 {
24 type: "musig",
25 host: "https://ark-live-musig.arkvault.io",
26 },
27 {
28 type: "explorer",
29 host: "https://explorer.ark.io",
30 },
31 ],
32 governance: {
33 delegateCount: 51,
34 votesPerWallet: 1,
35 votesPerTransaction: 1,
36 },
37 transactions,
38 importMethods,
39 featureFlags,
40 explorer,
41 knownWallets: "https://raw.githubusercontent.com/ArkEcosystem/common/master/mainnet/known-wallets-extended.json",
42 meta: {
43 fastDelegateSync: true,
44 },
45};
46 
47export default network;

packages/ark/source/networks/ark.mainnet.ts


1import { Networks } from "@ardenthq/sdk";
2 
3export const transactions: Networks.NetworkManifestTransactions = {
4 expirationType: "height",
5 types: [
6 "delegate-registration",
7 "delegate-resignation",
8 "htlc-claim",
9 "htlc-lock",
10 "htlc-refund",
11 "ipfs",
12 "multi-payment",
13 "multi-signature",
14 "second-signature",
15 "transfer",
16 "vote",
17 ],
18 fees: {
19 type: "dynamic",
20 ticker: "ARK",
21 },
22 memo: true,
23};
24 
25export const importMethods: Networks.NetworkManifestImportMethods = {
26 address: {
27 default: false,
28 permissions: ["read"],
29 },
30 bip39: {
31 default: true,
32 permissions: ["read", "write"],
33 },
34 publicKey: {
35 default: false,
36 permissions: ["read"],
37 },
38};
39 
40export const featureFlags: Networks.NetworkManifestFeatureFlags = {
41 Client: [
42 "transaction",
43 "transactions",
44 "wallet",
45 "wallets",
46 "delegate",
47 "delegates",
48 "votes",
49 "voters",
50 "configuration",
51 "fees",
52 "syncing",
53 "broadcast",
54 ],
55 Fee: ["all"],
56 Identity: [
57 "address.mnemonic.bip39",
58 "address.multiSignature",
59 "address.privateKey",
60 "address.publicKey",
61 "address.validate",
62 "address.wif",
63 "keyPair.mnemonic.bip39",
64 "keyPair.privateKey",
65 "keyPair.wif",
66 "privateKey.mnemonic.bip39",
67 "privateKey.wif",
68 "publicKey.mnemonic.bip39",
69 "publicKey.multiSignature",
70 "publicKey.wif",
71 "wif.mnemonic.bip39",
72 ],
73 Ledger: ["getVersion", "getPublicKey", "signTransaction", "signMessage"],
74 Link: ["block", "transaction", "wallet"],
75 Message: ["sign", "verify"],
76 Transaction: [
77 "delegateRegistration",
78 "delegateResignation",
79 "ipfs.ledgerS",
80 "ipfs.ledgerX",
81 "ipfs.musig",
82 "ipfs",
83 "multiPayment.ledgerS",
84 "multiPayment.ledgerX",
85 "multiPayment.musig",
86 "multiPayment",
87 "multiSignature.ledgerS",
88 "multiSignature.ledgerX",
89 "multiSignature.musig",
90 "multiSignature",
91 "secondSignature",
92 "transfer.ledgerS",
93 "transfer.ledgerX",
94 "transfer.musig",
95 "transfer",
96 "vote.ledgerS",
97 "vote.ledgerX",
98 "vote.musig",
99 "vote",
100 ],
101};
102 
103export const explorer: Networks.NetworkManifestExplorer = {
104 block: "block/{0}",
105 transaction: "transaction/{0}",
106 wallet: "wallets/{0}",
107};

packages/ark/source/networks/shared.ts


Checking for Supported Feature Flags

In the case of ARK it would be unsafe to call HDWallet.fromMnemonic(identity.mnemonic, { bip84: { account: 0 } }) because it would lead to an exception due to a lack of support for this specific way of retrieving a key-pair. Knowing that there is a lack of support for this feature before we even try to call the method will allow us to safe-guard our application against any unexpected behaviors for a certain coin.

A given coin’s network may be checked for supported features using the following pattern as an example:

1network.allows(FeatureFlag.IdentityAddressMnemonicBip84);

Available Feature Flags

Below is a list of all currently-available feature flags.

1export enum FeatureFlag {
2 AddressMnemonicBip39 = "Address.mnemonic.bip39",
3 AddressMnemonicBip44 = "Address.mnemonic.bip44",
4 AddressMnemonicBip49 = "Address.mnemonic.bip49",
5 AddressMnemonicBip84 = "Address.mnemonic.bip84",
6 AddressMultiSignature = "Address.multiSignature",
7 AddressPrivateKey = "Address.privateKey",
8 AddressPublicKey = "Address.publicKey",
9 AddressSecret = "Address.secret",
10 AddressValidate = "Address.validate",
11 AddressWif = "Address.wif",
12 ClientBroadcast = "Client.broadcast",
13 ClientDelegate = "Client.delegate",
14 ClientDelegates = "Client.delegates",
15 ClientTransaction = "Client.transaction",
16 ClientTransactions = "Client.transactions",
17 ClientVoters = "Client.voters",
18 ClientVotes = "Client.votes",
19 ClientWallet = "Client.wallet",
20 ClientWallets = "Client.wallets",
21 FeeAll = "Fee.all",
22 FeeCalculate = "Fee.calculate",
23 KeyPairMnemonicBip39 = "KeyPair.mnemonic.bip39",
24 KeyPairMnemonicBip44 = "KeyPair.mnemonic.bip44",
25 KeyPairMnemonicBip49 = "KeyPair.mnemonic.bip49",
26 KeyPairMnemonicBip84 = "KeyPair.mnemonic.bip84",
27 KeyPairPrivateKey = "KeyPair.privateKey",
28 KeyPairSecret = "KeyPair.secret",
29 KeyPairWif = "KeyPair.wif",
30 LedgerGetPublicKey = "Ledger.getPublicKey",
31 LedgerGetVersion = "Ledger.getVersion",
32 LedgerSignMessage = "Ledger.signMessage",
33 LedgerSignTransaction = "Ledger.signTransaction",
34 MessageSign = "Message.sign",
35 MessageVerify = "Message.verify",
36 PeerSearch = "Peer.search",
37 PrivateKeyMnemonicBip39 = "PrivateKey.mnemonic.bip39",
38 PrivateKeyMnemonicBip44 = "PrivateKey.mnemonic.bip44",
39 PrivateKeyMnemonicBip49 = "PrivateKey.mnemonic.bip49",
40 PrivateKeyMnemonicBip84 = "PrivateKey.mnemonic.bip84",
41 PrivateKeySecret = "PrivateKey.secret",
42 PrivateKeyWif = "PrivateKey.wif",
43 PublicKeyMnemonicBip39 = "PublicKey.mnemonic.bip39",
44 PublicKeyMnemonicBip44 = "PublicKey.mnemonic.bip44",
45 PublicKeyMnemonicBip49 = "PublicKey.mnemonic.bip49",
46 PublicKeyMnemonicBip84 = "PublicKey.mnemonic.bip84",
47 PublicKeyMultiSignature = "PublicKey.multiSignature",
48 PublicKeySecret = "PublicKey.secret",
49 PublicKeyWif = "PublicKey.wif",
50 TransactionDelegateRegistration = "Transaction.delegateRegistration",
51 TransactionDelegateRegistrationLedgerS = "Transaction.delegateRegistration.ledgerS",
52 TransactionDelegateRegistrationLedgerX = "Transaction.delegateRegistration.ledgerX",
53 TransactionDelegateResignation = "Transaction.delegateResignation",
54 TransactionDelegateResignationLedgerS = "Transaction.delegateResignation.ledgerS",
55 TransactionDelegateResignationLedgerX = "Transaction.delegateResignation.ledgerX",
56 TransactionHtlcClaim = "Transaction.htlcClaim",
57 TransactionHtlcClaimLedgerS = "Transaction.htlcClaim.ledgerS",
58 TransactionHtlcClaimLedgerX = "Transaction.htlcClaim.ledgerX",
59 TransactionHtlcLock = "Transaction.htlcLock",
60 TransactionHtlcLockLedgerS = "Transaction.htlcLock.ledgerS",
61 TransactionHtlcLockLedgerX = "Transaction.htlcLock.ledgerX",
62 TransactionHtlcRefund = "Transaction.htlcRefund",
63 TransactionHtlcRefundLedgerS = "Transaction.htlcRefund.ledgerS",
64 TransactionHtlcRefundLedgerX = "Transaction.htlcRefund.ledgerX",
65 TransactionIpfs = "Transaction.ipfs",
66 TransactionIpfsLedgerS = "Transaction.ipfs.ledgerS",
67 TransactionIpfsLedgerX = "Transaction.ipfs.ledgerX",
68 TransactionMultiPayment = "Transaction.multiPayment",
69 TransactionMultiPaymentLedgerS = "Transaction.multiPayment.ledgerS",
70 TransactionMultiPaymentLedgerX = "Transaction.multiPayment.ledgerX",
71 TransactionMultiSignature = "Transaction.multiSignature",
72 TransactionMultiSignatureLedgerS = "Transaction.multiSignature.ledgerS",
73 TransactionMultiSignatureLedgerX = "Transaction.multiSignature.ledgerX",
74 TransactionSecondSignature = "Transaction.secondSignature",
75 TransactionSecondSignatureLedgerS = "Transaction.secondSignature.ledgerS",
76 TransactionSecondSignatureLedgerX = "Transaction.secondSignature.ledgerX",
77 TransactionTransfer = "Transaction.transfer",
78 TransactionTransferLedgerS = "Transaction.transfer.ledgerS",
79 TransactionTransferLedgerX = "Transaction.transfer.ledgerX",
80 TransactionUnlockToken = "Transaction.unlockToken",
81 TransactionUnlockTokenLedgerS = "Transaction.unlockToken.ledgerS",
82 TransactionUnlockTokenLedgerX = "Transaction.unlockToken.ledgerX",
83 TransactionVote = "Transaction.vote",
84 TransactionVoteLedgerS = "Transaction.vote.ledgerS",
85 TransactionVoteLedgerX = "Transaction.vote.ledgerX",
86 WifMnemonicBip39 = "WIF.mnemonic.bip39",
87 WifMnemonicBip44 = "WIF.mnemonic.bip44",
88 WifMnemonicBip49 = "WIF.mnemonic.bip49",
89 WifMnemonicBip84 = "WIF.mnemonic.bip84",
90 WifSecret = "WIF.secret",
91}

packages/sdk/source/enums.ts

Last updated 1 year ago
Edit Page
Share: