@liquidapps/dapp-client

Dapp Client Library

The dapp-client library makes using DAPP Network services much easier. It also allows you to easily tap into the dappservices (core DAPP Network Smart contract) and dappairhodl1 (Air-HODL smart contract) RAM tables with precision utilizing secondary and tertiary indices without the hassle.
To setup the library, first install it:
1
npm i -g @liquidapps/dapp-client
Copied!
From there include the library’s client creator script:
1
const { createClient } = require('@liquidapps/dapp-client');
Copied!
Then pass your desired arguments to the creator function
1
/*
2
* network: specify your network of choice: mainnet, kylin, jungle
3
* httpEndpoint: you may also specify an endpoint to use instead of our defaults
4
* fetch: pass a fetch reference as needed
5
// if using dfuse
6
* dfuse_key: Dfuse API key
7
* dfuse_guarantee: Dfuse Push Guarantee(in-block, handoff:1, handoffs:2, handoffs:3, irreversible)
8
* dfuse_network: Dfuse Network ( mainnet, testnet (eosio testnet), kylin, worbli, wax)
9
*/
10
​
11
export const getClient = async() => {
12
return await createClient({ network: "kylin", httpEndpoint: endpoint, fetch: window.fetch.bind(window) });
13
};
Copied!
Finally, setup the service you would like to interact along with your smart contract name:
1
(async () => {
2
const service = await (await createClient()).service('ipfs','cardgame1112');
3
const response = await service.get_vram_row( "cardgame1112", "cardgame1112", "users", "nattests" );
4
console.log(response);
5
// { username: 'nattests',
6
// win_count: 0,
7
// lost_count: 0,
8
// game_data:
9
// { life_player: 5,
10
// life_ai: 5,
11
// deck_player:
12
// [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ],
13
// deck_ai:
14
// [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ],
15
// hand_player: [ 0, 0, 0, 0 ],
16
// hand_ai: [ 0, 0, 0, 0 ],
17
// selected_card_player: 0,
18
// selected_card_ai: 0,
19
// life_lost_player: 0,
20
// life_lost_ai: 0,
21
// status: 0 } }
22
})().catch((e) => { console.log(e); });
Copied!
Here is a full list of service options. The library comes with a push_guarantee function, similar to dfuse’s push guarantee, it accepts in-block, handoffs:1-3, or irreversible. There are DAPP Network service extensions and dappservices / dappairhodl1 RAM row calls.
Last modified 7mo ago
Copy link