# client

## Abstract Client

As previously mentioned you can use the `abstract-client` package to interact with any instance of   Abstract, including Bitsong's implementation. For this example we’ll use the `Mock` environment for simplicity. However, the same functions can be used for any `CwEnv`.

{% hint style="info" %}
&#x20;You can read the [`abstract-client` documentation](https://docs.rs/abstract-client/latest/abstract_client/) for more information.&#x20;
{% endhint %}

#### Example

```rust
    // Create environment
    let env: MockBech32 = MockBech32::new("mock");
    let sender: Addr = env.sender_addr();

    // Build the client
    let client: AbstractClient<MockBech32> = AbstractClient::builder(env.clone()).build_mock()?;
```

These three lines:

1. Created a mock environment to deploy to.
2. Deployed `Abstract` to that environment and returned a client. You can then start using the client to do all sorts of things. For example, you can set and query balances easily.

```rust
    let coins = &[Coin::new(50u128, "btsg"), Coin::new(20u128, "btc")];

    // Set a balance
    client.set_balance(&sender, coins)?;

    // Add to an address's balance
    client.add_balance(&sender, &[Coin::new(50u128, "btsg")])?;

    // Query an address's balance
    let btsg_balance = client.query_balance(&sender, "btsg")?;

    assert_eq!(btsg_balance.u128(), btsg);
```

Then, you can use the client to create a `Publisher` to publish an App to the platform.

```rust
    // Create a publisher
    let publisher: Publisher<MockBech32> = client
        .account_builder()
        .namespace(Namespace::from_id(TEST_MODULE_ID)?)
        .build()?
        .publisher()?;

    // Publish an app
    publisher.publish_app::<MockAppI<MockBech32>>()?;
```

Now that the App is published anyone can create an `Account` and install it!

```rust
    let accounti: Account<MockBech32> = client.account_builder().build()?;

    // Install an app
    let app: Application<MockBech32, MockAppI<MockBech32>> =
        accounti.install_app::<MockAppI<MockBech32>>(&MockInitMsg {}, &[])?;
```

Et voila! You’ve just deployed `Abstract` and an App to a mock environment. You can now start testing your module.

The `Account` object also has some useful helper methods:

```rust
    // Get account info
    let account_info: AccountInfo = accounti.info()?;
    // Get the owner
    let owner: Addr = accounti.owner()?;
    // Add or set balance
    accounti.add_balance(&[Coin::new(100u128, "btsg")])?;
    // ...
```

You can explore more of its functions in the [type’s documentation](https://docs.rs/abstract-client/latest/abstract_client/struct.Account.html).


---

# 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.bitsong.io/products/bitsong-accounts/abstract-accounts-on-bitsong/developers/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.
