> For the complete documentation index, see [llms.txt](https://mars-protocol.gitbook.io/mars-protocol/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mars-protocol.gitbook.io/mars-protocol/contracts-core/tokenomics/xmars-token.md).

# xMARS Token

The xMARS Token contract is a Cw20 fork with added snapshot functionality in order to compute voting power for proposals. xMARS are minted by the Staking contract when addresses stake MARS.

## Links

* package (msgs and types): <https://github.com/mars-protocol/mars-core/blob/master/packages/mars-core/src/xmars_token.rs>
* contract:  <https://github.com/mars-protocol/mars-core/blob/master/contracts/mars-xmars-token/src/contract.rs>
* schema: <https://github.com/mars-protocol/mars-core/tree/master/contracts/mars-xmars-token/schema>

## QueryMsg

### `Balance`

Returns the current balance of the given address, 0 if unset.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Balance {
        address: String
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
  "balance": {
    "address": "terra..."
  }
}
```

{% endtab %}
{% endtabs %}

| Key       | Type   | Description                            |
| --------- | ------ | -------------------------------------- |
| `address` | String | Address to return current balance from |

### `BalanceAt`

Returns the balance of the given address at a given block.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    BalanceAt {
        address: String,
        block: u64
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
  "balance_at": {
    "address": "terra...",
    "block": 999
  }
}
```

{% endtab %}
{% endtabs %}

| Key       | Type   | Description                          |
| --------- | ------ | ------------------------------------ |
| `address` | String | Address to return balance from       |
| `block`   | u64    | Current block to return balance from |

### `TokenInfo`

Returns metadata on the contract - name, decimals, supply, etc.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    TokenInfo {}
}
```

{% endtab %}

{% tab title="JSON" %}

```json
 {
  "token_info": {}
}
```

{% endtab %}
{% endtabs %}

### `TotalSupplyAt`

Total Supply at a given block.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    TotalSupplyAt {
        block: u64
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
  "total_supply_at": {
    "block": 999
  }
}
```

{% endtab %}
{% endtabs %}

| Key     |     |                                      |
| ------- | --- | ------------------------------------ |
| `block` | u64 | Current block to return total supply |

### `Minter`

Returns the minter of the contract.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Minter {}
}
```

{% endtab %}

{% tab title="JSON" %}

```json
 {
  "minter": {}
}
```

{% endtab %}
{% endtabs %}

### `Allowance`

Only with "allowance" extension. Returns how much spender can use from owner account, 0 if unset.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    Allowance {
        owner: String,
        spender: String
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
  "allowance": {
    "owner": "terra...",
    "spender": "terra..."
  }
}
```

{% endtab %}
{% endtabs %}

| Key       | Type   | Description              |
| --------- | ------ | ------------------------ |
| `owner`   | String | Owner contract address   |
| `spender` | String | Spender contract address |

### `AllAllowances`

Only with "enumerable" extension (and "allowances"). Returns all allowances this owner has approved. Supports pagination.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    AllAllowances {
        owner: String,
        start_after: Option<String>,
        limit: Option<u32>
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
  "all_allowances": {
    "owner": "terra...",
    "start_after": "terra...",
    "limit": 10
  }
}
```

{% endtab %}
{% endtabs %}

| Key             | Type   | Description                                       |
| --------------- | ------ | ------------------------------------------------- |
| `owner`         | String | Owner address to return  approved allowances from |
| `start_after`\* | String | Address to start after                            |
| `limit`\*       | u32    | Limit of query return                             |

\* = optional

### `AllAccounts`

Only with "enumerable" extension. Returns all accounts that have balances. Supports pagination.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    AllAccounts {
        start_after: Option<String>,
        limit: Option<u32>
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
  "all_accounts": {
    "start_after": "terra...",
    "limit": 10
  }
}
```

{% endtab %}
{% endtabs %}

| Key             | Type   | Description            |
| --------------- | ------ | ---------------------- |
| `start_after`\* | String | Address to start after |
| `limit`\*       | u32    | Limit of query return  |

\* = optional

### `MarketingInfo`

Only with "marketing" extension. Returns more metadata on the contract to display in the client: description, logo, project url, etc.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    MarketingInfo {}
}
```

{% endtab %}

{% tab title="JSON" %}

```json
 {
  "marketing_info": {}
}
```

{% endtab %}
{% endtabs %}

### `DownloadLogo`

Only with "marketing" extension. ownloads the mbeded logo data (if stored on chain). Errors if no logo data ftored for this contract.

{% tabs %}
{% tab title="Rust" %}

```rust
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
    DownloadLogo {}
}
```

{% endtab %}

{% tab title="JSON" %}

```json
 {
  "download_logo": {}
}
```

{% endtab %}
{% endtabs %}
