# @liquidapps/dapp-client

## Dapp Client Library

The [dapp-client library](https://www.npmjs.com/package/@liquidapps/dapp-client) makes using DAPP Network services much easier. It also allows you to easily tap into the [`dappservices`](https://bloks.io/account/dappservices) (core DAPP Network Smart contract) and [`dappairhodl1`](https://bloks.io/account/dappairhodl1) (Air-HODL smart contract) RAM tables with precision utilizing secondary and tertiary indices without the hassle.

To setup the library, first install it:

```
npm i -g @liquidapps/dapp-client
```

From there include the library’s client creator script:

```
const { createClient } = require('@liquidapps/dapp-client');
```

Then pass your desired arguments to the creator function

```
/*
    * network: specify your network of choice: mainnet, kylin, jungle 
    * httpEndpoint: you may also specify an endpoint to use instead of our defaults
    * fetch: pass a fetch reference as needed
    // if using dfuse
    * dfuse_key: Dfuse API key
    * dfuse_guarantee: Dfuse Push Guarantee(in-block, handoff:1, handoffs:2, handoffs:3, irreversible)
    * dfuse_network: Dfuse Network ( mainnet, testnet (eosio testnet), kylin, worbli, wax)
*/

export const getClient = async() => {
  return await createClient({ network: "kylin", httpEndpoint: endpoint, fetch: window.fetch.bind(window) });
};
```

Finally, setup the service you would like to interact along with your smart contract name:

```
(async () => {
    const service = await (await createClient()).service('ipfs','cardgame1112');
    const response = await service.get_vram_row( "cardgame1112", "cardgame1112", "users", "nattests" );
    console.log(response);
    // { username: 'nattests',
    //     win_count: 0,
    //     lost_count: 0,
    //     game_data:
    // { life_player: 5,
    //     life_ai: 5,
    //     deck_player:
    //     [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ],
    //     deck_ai:
    //     [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 ],
    //     hand_player: [ 0, 0, 0, 0 ],
    //     hand_ai: [ 0, 0, 0, 0 ],
    //     selected_card_player: 0,
    //     selected_card_ai: 0,
    //     life_lost_player: 0,
    //     life_lost_ai: 0,
    //     status: 0 } }
})().catch((e) => { console.log(e); });
```

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`](https://bloks.io/account/dappservices) / [`dappairhodl1`](https://bloks.io/account/dappairhodl1) RAM row calls.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.liquidapps.io/liquidapps-documentation/introduction/dapp-network-resources/liquidapps-dapp-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
