> For the complete documentation index, see [llms.txt](https://docs.exsat.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.exsat.network/developer-guides/native-layer-developer-guides/exsat-consensus-contracts/staking-contract.md).

# Staking Contract

## &#x20;staking.xsat

### Actions

* Add a staking token
* Remove a staking token
* Set the token's staking disable status
* Unstake tokens
* Withdraw tokens that have reached their expiration time

### Quickstart

```bash
# addtoken @staking.xsat
$ cleos push action staking.xsat addtoken '[{ "sym": "8,BTC", "contract": "btc.xsat" }]' -p staking.xsat

# deltoken @staking.xsat
$ cleos push action staking.xsat deltoken '[1]' -p staking.xsat

# setstatus @staking.xsat
$ cleos push action staking.xsat setstatus '{"id": 1, "disabled_staking": true}' -p staking.xsat

# staking @staker
$ cleos push action btc.xsat transfer '{"from":"alice","to":"staking.xsat","quantity":"1.00000000 BTC", "memo":"alice"}' -p alice

# release @staker
$ cleos push action staking.xsat release '{"staking_id": 1, "staker": "alice", "validator": "alice", "quantity": "1.00000000 BTC"}' -p alice

# withdraw @staker
$ cleos push action staking.xsat withdraw '{"staker": "alice"}' -p alice
```

### Table Information

```bash
$ cleos get table rescmng.xsat staking.xsat globalid
$ cleos get table rescmng.xsat staking.xsat tokens
$ cleos get table rescmng.xsat <staker> staking
$ cleos get table rescmng.xsat <staker> releases
```

### TABLE `globalid`

#### scope&#x20;

staking.xsat

#### params

* `{uint64_t} staking_id` - the latest staking id
* `{uint64_t} release_id` - the latest release id

#### example

```json
{
  "staking_id": 1,
  "release_id": 1
}
```

### TABLE `tokens`

#### scope&#x20;

staking.xsat

#### params

* `{uint64_t} id` - token id
* `{uint64_t} token` - whitelist token
* `{bool} disabled_staking` - whether to disable staking

#### example

```json
{
  "id": 1,
  "token": { "sym": "8,BTC", "contract": "btc.xsat" },
  "disabled_staking": false
}
```

### TABLE `staking`

#### scope `staker`

#### params

* `{uint64_t} id` - staking id
* `{extended_asset} quantity` - total number of staking

#### example

```json
{
  "id": 1,
  "quantity": {"quantity":"1.00000000 BTC", "contract":"btc.xsat"}
}
```

### TABLE `releases`

#### scope `staker`

#### params

* `{uint64_t} id` - release id
* `{extended_asset} quantity` - unpledged quantity
* `{time_point_sec} expiration_time` - cancel pledge expiration time

#### example

```json
{
  "id": 1,
  "quantity": {
      "quantity": "1.00000000 BTC",
      "contract": "btc.xsat"
  },
  "expiration_time": "2024-08-12T08:09:57"
}
```

### ACTION `addtoken`

* **authority**: staking.xsat

> Add whitelist token

#### params

* `{extended_symbol} token` - token to add

#### example

```bash
$ cleos push action staking.xsat addtoken '[{ "sym": "8,BTC", "contract": "btc.xsat" }]' -p staking.xsat
```

### ACTION `deltoken`

* **authority**: staking.xsat

> Delete whitelist token

#### params

* `{uint64_t} id` - token id to be deleted

#### example

```bash
$ cleos push action staking.xsat deltoken '[1]' -p staking.xsat
```

### ACTION `setstatus`

* **authority**: staking.xsat

> Set the token’s disabled staking status.

#### params

* `{uint64_t} id` - token id
* `{bool} disabled_staking` - whether to disable staking

#### example

```bash
$ cleos push action staking.xsat setstatus '[1, true]' -p staking.xsat
```

### ACTION `release`

* **authority**: `staker`

> Cancel the pledge and enter the unlocking period.

#### params

* `{uint64_t} staking_id` - staking id
* `{name} staker` - staker account
* `{name} validator` - the validator account to be pledged to
* `{extended_asset} quantity` - unpledged quantity

#### example

```bash
$ cleos push action staking.xsat release '[1, "alice", "alice", "1.00000000 BTC"]' -p alice
```

### ACTION `withdraw`

* **authority**: `staker`

> Withdraw expired staking tokens.

#### params

* `{name} staker` - staker account

#### example

```bash
$ cleos push action staking.xsat withdraw '["alice"]' -p alice
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.exsat.network/developer-guides/native-layer-developer-guides/exsat-consensus-contracts/staking-contract.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
