> For the complete documentation index, see [llms.txt](https://docs.sourceprotocol.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sourceprotocol.io/smart-contracts-and-sourced-development/cw1-tutorial/initialize-the-contract.md).

# Initialize the Contract

{% hint style="danger" %}
We don't specify it here, but in almost all cases you should provide an `--admin` address when instantiating a contract. If you do not, you will not be able to migrate the contract later.
{% endhint %}

CosmWasm Smart Contracts take their arguments as serialized JSON. This can be created a number of ways, but as we showed in the previous examples, it may well be easiest to use the `node` command line, if that is available to you.

{% hint style="info" %}
There is a Typescript helpers file for most contracts, and extensions for CosmJS, but at the time of writing, they are broken. This will no doubt be fixed soon, providing an alternative way of interacting with contracts other than the CLI.
{% endhint %}

To use the node REPL, type `node` in the terminal.

```javascript
const initobj = {
  admins: ["<your-validator-self-delegate-key>"],
  mutable: false
};

< undefined

JSON.stringify(initobj);

< '{"admins":["<your-validator-self-delegate-key>"],"mutable":false}'
```

With these encoded arguments, you can now instantiate the contract, using the `code_id` from the previous step.

```bash
sourced tx wasm instantiate <code-id> '{"admins":["<your-validator-self-delegate-key>"],"mutable":false}' --amount 50000usource --label "CW1 example contract" --from <your-key> --chain-id <chain-id> \
  --gas-prices 0.1usource --gas auto --gas-adjustment 1.3 -b block -y
```

Once the contract is instantiated, you can find out its contract address:

```bash
sourced query wasm list-contract-by-code <code-id>
```

You will need this to interact with the contract.


---

# 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.sourceprotocol.io/smart-contracts-and-sourced-development/cw1-tutorial/initialize-the-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.
