# Stacking

## Stack CityCoins

{% hint style="info" %}
Requires:

* `@stacks/network`
* `@stacks/transactions`
* `@stacks/connect-react`
  {% endhint %}

```
// example: stack CityCoins for the next active cycle

const NETWORK = new StacksMainnet(); // set network from @stacks/network
const { doContractCall } = useConnect(); // hook for Stacks Connect

const amount = 250000; // amount of CityCoins
const cycles = 5; // cycles to lock for
const amountCV = uintCV(amount);
const cyclesCV = uintCV(cycles);

try {
  await doContractCall({
    contractAddress: 'SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27',
    contractName: 'miamicoin-core-v1',
    functionName: 'stack-tokens',
    functionArgs: [amountCV, cyclesCV],
    postConditionMode: PostConditionMode.Deny,
    postConditions: [
      makeStandardFungiblePostCondition(
        ownerStxAddress,
        FungibleConditionCode.Equal,
        amountCV.value,
        createAssetInfo('SP466FNC0P7JWTNM2R9T199QRZN1MYEDTAR0KP27', 'miamicoin-token', 'miamicoin')
      ),
    ],
    network: NETWORK,
    onCancel: () => {
      // what to do if tx is canceled / window is closed
      console.log('Transaction canceled, please try again');
    },
    onFinish: result => {
      // what to if tx is successfully broadcasted
      console.log(`Transaction successfully broadcasted:\n${result.txId}`);
    },
  });
} catch (err) {
  console.log(`Error: ${err.message}`);
}
```


---

# 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.citycoins.co/developer-resources/code-examples/stacking.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.
