antelopeql 3.0.0-rc.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/antelopeql.d.ts +32 -27
- package/dist/antelopeql.js +47 -37
- package/dist/antelopeql.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
- package/readme.md +42 -41
package/dist/antelopeql.d.ts
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SignTransactionContext } from "antelopeql";
|
|
2
2
|
import { type GraphQLError, type GraphQLFieldConfig } from "graphql";
|
|
3
|
-
|
|
3
|
+
export interface AntelopeQLRequest {
|
|
4
4
|
query: string;
|
|
5
5
|
operationName?: string | null;
|
|
6
|
-
variables?: any;
|
|
7
|
-
}
|
|
6
|
+
variables?: Record<string, any> | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* List of Antelope chains.
|
|
10
|
+
*/
|
|
8
11
|
declare type ChainsType = "vaulta" | "telos" | "xpr" | "wax" | "jungle" | string;
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Lists you smart contracts across the various Antelope chains.
|
|
14
|
+
*/
|
|
15
|
+
export declare type ContractsType = {
|
|
10
16
|
[key in ChainsType]?: string[];
|
|
11
17
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Enables you to enhance your GraphQL schema to add auxiliary queries and mnutation fields to your API.
|
|
20
|
+
*/
|
|
21
|
+
declare type ExtendQueryType = {
|
|
22
|
+
query?: {
|
|
23
|
+
[name in string]: GraphQLFieldConfig<unknown, unknown, unknown>;
|
|
17
24
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
abiFetchOptions?: RequestInit;
|
|
22
|
-
/**
|
|
23
|
-
* Handles the fetch request options of requests to blockchain
|
|
24
|
-
*/
|
|
25
|
-
fetchOptions?: RequestInit;
|
|
26
|
-
/**
|
|
27
|
-
* Extend the default Query scema by providing a custom GraphQL Query type.
|
|
28
|
-
*/
|
|
29
|
-
extendQueryType?: {
|
|
30
|
-
query: {
|
|
31
|
-
[name in string]: GraphQLFieldConfig<unknown, unknown, unknown>;
|
|
32
|
-
};
|
|
25
|
+
mutation?: {
|
|
26
|
+
[name in string]: GraphQLFieldConfig<unknown, unknown, unknown>;
|
|
33
27
|
};
|
|
34
28
|
};
|
|
35
|
-
declare type
|
|
29
|
+
export declare type APIOptionsType = {
|
|
30
|
+
signTransaction?: SignTransactionContext;
|
|
31
|
+
contracts?: ContractsType;
|
|
32
|
+
chains?: {
|
|
33
|
+
[chain_name in ChainsType]: URL | string;
|
|
34
|
+
};
|
|
35
|
+
fetchOptions?: RequestInit;
|
|
36
|
+
abiFetchOptions?: RequestInit;
|
|
37
|
+
extendQuery?: ExtendQueryType;
|
|
38
|
+
};
|
|
39
|
+
export declare type AntelopeQLResult = {
|
|
36
40
|
data?: any;
|
|
37
41
|
errors?: ReadonlyArray<GraphQLError>;
|
|
38
42
|
};
|
|
39
|
-
export declare
|
|
43
|
+
export declare const default_rpc_urls: { [chain in ChainsType]: string | URL; };
|
|
44
|
+
export declare function AntelopeQL({ query, variables, operationName }: AntelopeQLRequest, options?: APIOptionsType): Promise<AntelopeQLResult>;
|
|
40
45
|
export {};
|
package/dist/antelopeql.js
CHANGED
|
@@ -1,24 +1,38 @@
|
|
|
1
|
-
import create_wa_signature from "antelope-webauthn/create_wa_signature";
|
|
2
1
|
import { blockchain_query_field, build_graphql_fields_from_abis, get_abis, send_serialized_transaction, send_transaction, serialize_transaction, actions_type as actions } from "antelopeql";
|
|
3
2
|
import { execute, GraphQLObjectType, GraphQLSchema, parse, Source, validate } from "graphql";
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const defaultChains = [
|
|
4
|
+
"vaulta",
|
|
5
|
+
"telos",
|
|
6
|
+
"xpr",
|
|
7
|
+
"wax",
|
|
8
|
+
"jungle"
|
|
9
|
+
];
|
|
10
|
+
export const default_rpc_urls = {
|
|
11
|
+
// Chain - aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906
|
|
12
|
+
vaulta: "https://eos.relocke.io",
|
|
13
|
+
// Chain - 4667b205c6838ef70ff7988f6e8257e8be0e1284a2f59699054a018f743b1d11
|
|
14
|
+
telos: "https://telos.relocke.io",
|
|
15
|
+
// chain - 384da888112027f0321850a169f737c33e53b388aad48b5adace4bab97f437e0
|
|
16
|
+
xpr: "https://proton.relocke.io",
|
|
17
|
+
// chain - 1064487b3cd1a897ce03ae5b6a865651747e2e152090f99c1d19d44e01aea5a4
|
|
18
|
+
wax: "https://wax.relocke.io",
|
|
19
|
+
// Chain - 73e4385a2708e6d7048834fbc1079f2fabb17b3c125b146af438971e90716c4d
|
|
20
|
+
jungle: "https://jungle.relocke.io"
|
|
11
21
|
};
|
|
12
|
-
export async function AntelopeQL({ query, variables, operationName },
|
|
22
|
+
export async function AntelopeQL({ query, variables, operationName }, options) {
|
|
23
|
+
const build_chains = new Set(defaultChains);
|
|
24
|
+
if (options?.chains)
|
|
25
|
+
Object.keys(options?.chains).forEach((chain) => build_chains.add(chain));
|
|
26
|
+
const chains = [...build_chains];
|
|
13
27
|
const fields = {};
|
|
14
28
|
const mutationFields = {};
|
|
15
29
|
for await (const chain of chains) {
|
|
16
|
-
const rpc_url =
|
|
17
|
-
const contracts =
|
|
30
|
+
const rpc_url = options?.chains?.[chain] ?? default_rpc_urls[chain];
|
|
31
|
+
const contracts = options?.contracts?.[chain] ?? [];
|
|
18
32
|
const typeResolution = chain.padStart(!chain.length ? 0 : chain.length + 1, "_");
|
|
19
33
|
const abis = (await get_abis(contracts, {
|
|
20
34
|
rpc_url,
|
|
21
|
-
fetchOptions:
|
|
35
|
+
fetchOptions: options?.abiFetchOptions
|
|
22
36
|
}));
|
|
23
37
|
const T = abis.map((x) => ({
|
|
24
38
|
account_name: x.account_name,
|
|
@@ -48,36 +62,34 @@ export async function AntelopeQL({ query, variables, operationName }, apiOptions
|
|
|
48
62
|
fields: {
|
|
49
63
|
send_serialized_transaction,
|
|
50
64
|
...(Object.keys(mutation_fields)?.length
|
|
51
|
-
? {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
})()
|
|
64
|
-
}
|
|
65
|
+
? (() => {
|
|
66
|
+
const a = actions(mutation_fields, typeResolution);
|
|
67
|
+
const serialize_transaction_type = serialize_transaction(a, ast_list);
|
|
68
|
+
const map = {
|
|
69
|
+
serialize_transaction: serialize_transaction_type
|
|
70
|
+
};
|
|
71
|
+
if (options?.signTransaction) {
|
|
72
|
+
map.send_transaction = send_transaction(a, ast_list);
|
|
73
|
+
}
|
|
74
|
+
return map;
|
|
75
|
+
})()
|
|
65
76
|
: {})
|
|
66
77
|
}
|
|
67
78
|
})
|
|
68
79
|
};
|
|
69
80
|
}
|
|
70
|
-
const extended_query =
|
|
81
|
+
const extended_query = options?.extendQuery?.query ?? {};
|
|
71
82
|
const queries = new GraphQLObjectType({
|
|
72
83
|
name: "Query",
|
|
73
84
|
fields: {
|
|
74
|
-
...
|
|
75
|
-
...
|
|
85
|
+
...fields,
|
|
86
|
+
...extended_query
|
|
76
87
|
}
|
|
77
88
|
});
|
|
89
|
+
const extended_mutation = options?.extendQuery?.mutation ?? {};
|
|
78
90
|
const mutations = new GraphQLObjectType({
|
|
79
91
|
name: "Mutation",
|
|
80
|
-
fields: mutationFields
|
|
92
|
+
fields: { ...mutationFields, ...extended_mutation }
|
|
81
93
|
});
|
|
82
94
|
const schema = new GraphQLSchema({ query: queries, mutation: mutations });
|
|
83
95
|
const document = parse(new Source(query));
|
|
@@ -96,14 +108,12 @@ export async function AntelopeQL({ query, variables, operationName }, apiOptions
|
|
|
96
108
|
.replace(/_mutation$/gmu, "")
|
|
97
109
|
: getFieldPath(path.prev, path);
|
|
98
110
|
const chain = getFieldPath(info.path);
|
|
99
|
-
const rpc_url =
|
|
100
|
-
return { rpc_url, fetchOptions:
|
|
111
|
+
const rpc_url = options?.chains?.[chain] ?? default_rpc_urls[chain];
|
|
112
|
+
return { rpc_url, fetchOptions: options?.fetchOptions };
|
|
101
113
|
},
|
|
102
|
-
async signTransaction(hash) {
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
const signature = await create_wa_signature([apiOptions.device_key], hash);
|
|
106
|
-
return [signature];
|
|
114
|
+
async signTransaction(hash, serialized_transaction, transaction) {
|
|
115
|
+
if (options?.signTransaction)
|
|
116
|
+
return options?.signTransaction(hash, serialized_transaction, transaction);
|
|
107
117
|
}
|
|
108
118
|
},
|
|
109
119
|
variableValues: variables,
|
package/dist/antelopeql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antelopeql.js","sourceRoot":"","sources":["../src/antelopeql.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"antelopeql.js","sourceRoot":"","sources":["../src/antelopeql.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,QAAQ,EACR,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,IAAI,OAAO,EAKxB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,aAAa,EACb,KAAK,EACL,MAAM,EACN,QAAQ,EAMT,MAAM,SAAS,CAAC;AAoDjB,MAAM,aAAa,GAAG;IACpB,QAAQ;IACR,OAAO;IACP,KAAK;IACL,KAAK;IACL,QAAQ;CACO,CAAC;AAElB,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,2EAA2E;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AC,CAAC,EAAE,QAAQ,IAAI,EAAE,CAAC;yBAChB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;yBACzB,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;oBACjC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAEpC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAe,CAAC;gBACpD,MAAM,OAAO,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,gBAAgB,CAAC,KAAK,CAAC,CAAC;gBAEpE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;YAC1D,CAAC;YACD,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,sBAAsB,EAAE,WAAW;gBAC7D,IAAI,OAAO,EAAE,eAAe;oBAC1B,OAAO,OAAO,EAAE,eAAe,CAC7B,IAAI,EACJ,sBAAsB,EACtB,WAAW,CACZ,CAAC;YACN,CAAC;SACS;QACZ,cAAc,EAAE,SAAS;QACzB,aAAa;QACb,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE;YACrD,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;QAC9B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AntelopeQL } from "./antelopeql.js";
|
|
1
|
+
export { AntelopeQL, default_rpc_urls, type AntelopeQLRequest, type APIOptionsType, type AntelopeQLResult, type ContractsType } from "./antelopeql.js";
|
|
2
2
|
export { serialize_transaction } from "./serialize_transaction.js";
|
|
3
3
|
export { serialize_abi } from "./serialize_abi.js";
|
|
4
4
|
export { send_transaction, type SerializedTransaction } from "./send_transaction.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AntelopeQL } from "./antelopeql.js";
|
|
1
|
+
export { AntelopeQL, default_rpc_urls } from "./antelopeql.js";
|
|
2
2
|
export { serialize_transaction } from "./serialize_transaction.js";
|
|
3
3
|
export { serialize_abi } from "./serialize_abi.js";
|
|
4
4
|
export { send_transaction } from "./send_transaction.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,gBAAgB,EAKjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,gBAAgB,EAEjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,oBAAoB,EAErB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAC;AAC3D,OAAO,EACL,8BAA8B,EAE/B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,yBAAy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AAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antelopeql",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A GraphQL implementation for interacting with Antelope based blockchains.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"eslint": "eslint .",
|
|
17
17
|
"prettier": "prettier -c .",
|
|
18
18
|
"prettier:readme": "prettier --write readme.md",
|
|
19
|
-
"server": "
|
|
19
|
+
"server": "node test/server.js",
|
|
20
20
|
"types": "tsc -p jsconfig.json",
|
|
21
21
|
"prepublishOnly": "npm run build && npm run test"
|
|
22
22
|
},
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"antelope-ecc": "^5.0.0",
|
|
76
|
-
"antelope-webauthn": "^2.0.0",
|
|
77
76
|
"base58-js": "^3.0.3",
|
|
78
77
|
"eosio-wasm-js": "^5.0.2",
|
|
79
78
|
"ripemd160-js": "^3.0.4"
|
package/readme.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.org/package/antelopeql) [](https://github.com/pur3miish/antelopeql/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
AntelopeQL (_Antelope Query Language_)
|
|
7
|
+
AntelopeQL (_Antelope Query Language_).
|
|
8
8
|
|
|
9
9
|
AntelopeQL is a GraphQL client and server library that allows developers to interact with the Antelope blockchain using GraphQL. It provides a unified interface to communicate with different blockchains within the Antelope ecosystem, enabling developers to leverage the unique features and capabilities of each blockchain while still benefiting from a consistent development experience.
|
|
10
10
|
|
|
@@ -12,6 +12,8 @@ As a GraphQL client library, AntelopeQL simplifies the process of building and e
|
|
|
12
12
|
|
|
13
13
|
With AntelopeQL, developers can focus on building the frontend and business logic of their DApps, while relying on the library to handle the complexities of interacting with multiple blockchains in the Antelope ecosystem.
|
|
14
14
|
|
|
15
|
+
**Live working example can be found [here](https://relocke.io/api/playground).**
|
|
16
|
+
|
|
15
17
|

|
|
16
18
|
|
|
17
19
|
## Installation
|
|
@@ -26,77 +28,76 @@ npm install antelopeql graphql
|
|
|
26
28
|
|
|
27
29
|
See the examples folder on how to run AntelopeQL as a [Node.js](https://nodejs.org) endpoint.
|
|
28
30
|
|
|
29
|
-
### Query a
|
|
31
|
+
### Query a Blockchain Account Info
|
|
30
32
|
|
|
31
33
|
```js
|
|
32
34
|
import { AntelopeQL } from "antelopeql";
|
|
33
35
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const query = /* GraphQL */ `
|
|
37
|
+
{
|
|
38
|
+
vaulta {
|
|
39
|
+
get_blockchain {
|
|
40
|
+
get_account(account_name: "relockeblock") {
|
|
38
41
|
core_liquid_balance
|
|
39
42
|
ram_quota
|
|
40
43
|
net_weight
|
|
41
44
|
cpu_weight
|
|
42
45
|
ram_usage
|
|
43
|
-
permissions {
|
|
44
|
-
linked_actions {
|
|
45
|
-
account
|
|
46
|
-
action
|
|
47
|
-
}
|
|
48
|
-
required_auth {
|
|
49
|
-
keys {
|
|
50
|
-
key
|
|
51
|
-
weight
|
|
52
|
-
}
|
|
53
|
-
threshold
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const { data } = await AntelopeQL({ query });
|
|
61
53
|
|
|
62
54
|
console.log(data);
|
|
63
55
|
```
|
|
64
56
|
|
|
65
57
|
> Logged output included an account infomation.
|
|
66
58
|
|
|
67
|
-
### Transfer
|
|
59
|
+
### Transfer Tokens
|
|
68
60
|
|
|
69
61
|
```js
|
|
70
62
|
import { AntelopeQL } from "antelopeql";
|
|
71
63
|
import sign_txn from "antelopeql-ecc/sign_txn.js";
|
|
72
64
|
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
send_transaction(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
65
|
+
const query = /* GraphQL */ `
|
|
66
|
+
mutation {
|
|
67
|
+
jungle {
|
|
68
|
+
send_transaction(
|
|
69
|
+
actions: [
|
|
70
|
+
{
|
|
71
|
+
eosio_token: {
|
|
72
|
+
transfer: {
|
|
73
|
+
authorization: { actor: "relockeblock" }
|
|
74
|
+
to: "relockechain"
|
|
75
|
+
from: "relockeblock"
|
|
76
|
+
memo: ""
|
|
77
|
+
quantity: "0.0002 EOS"
|
|
78
|
+
}
|
|
81
79
|
}
|
|
82
|
-
to:"relockechain"
|
|
83
|
-
from:"relockeblock"
|
|
84
|
-
memo: ""
|
|
85
|
-
quantity: "0.0002 EOS"
|
|
86
80
|
}
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
]
|
|
82
|
+
) {
|
|
89
83
|
transaction_id
|
|
90
84
|
block_num
|
|
91
85
|
}
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
`;
|
|
89
|
+
|
|
90
|
+
const { data } = await AntelopeQL({
|
|
91
|
+
query,
|
|
92
|
+
contracts: {
|
|
93
|
+
// List of your smart contracts accounts for each chains.
|
|
94
|
+
jungle: ["eosio.token"]
|
|
95
|
+
},
|
|
94
96
|
signTransaction: async (hash) => {
|
|
95
97
|
const wif_private_key = "PVT_K1_…"; // your private key
|
|
96
98
|
const signature = await sign_txn({ hash, wif_private_key });
|
|
97
99
|
return [signature]; // signatures must return array
|
|
98
|
-
}
|
|
99
|
-
rpc_url: "https://eos.relocke.io" // eos blockchain url.
|
|
100
|
+
}
|
|
100
101
|
});
|
|
101
102
|
|
|
102
103
|
console.log(data);
|