> For the complete documentation index, see [llms.txt](https://nomos-docs.gitbook.io/nomos-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nomos-docs.gitbook.io/nomos-1/readme/nomos-sdk/examples.md).

# Examples

### Sending funds

For this proposal to work, the multisig must have a balance x >= amount sent.

<pre class="language-typescript"><code class="lang-typescript"><strong>const {transactionHash, proposal} = await multisig.createProposal({
</strong>  from: "&#x3C;sender address>",
  description: "&#x3C;proposal description&#x3C;",
  messages: [
    {
      bank: {
        send: {
          amount: [
            {
              denom: "&#x3C;network denom>", //"aarch" in archway mainnet
              amount: "&#x3C;amount to send",
            },
          ],
          to_address: receiverAddr,
        },
      },
    },
  ],
});
</code></pre>

### Instantiate any contract

To instantiate any contract you must pass the correct instantiateMessage that creates the contract. Then encode it base64 and create a wasm.instantiate message.

```typescript
//this object depends on the contract to instantiate
let instantiateMessage = JSON.stringify({});
let msgBin = Buffer.from(instantiateMessage).toString("base64");

const {proposal, transactionHash} = await multisig.createProposal({
  from: "<sender address>",
  description: "<proposal description>",
  messages: [
    {
      wasm: {
        instantiate: {
          admin: "<admin of contract>,
          code_id: <contract codeID>,
          funds: [],
          label: "<contract label>",
          msg: msgBin,
        },
      },
    },
  ],
});

```

### Transfer CW20 tokens

Any contract related transaction should have the message to send wrapped inside a wasm.execute. On this example we create a message to transfer 1 CW20 token with 18 decimal places.

```typescript
const msg = Buffer.from(
  JSON.stringify({
    transfer: {
      amount: new BigNumber("1").multipliedBy(new BigNumber("1e18")),
      recipient: "<receiver address>",
    },
  })
).toString("base64");

const {proposal, transactionHash} = await multisig.createProposal({
  from: "<sender address>",
  description: "<proposal description",
  messages: [
    {
      wasm: {
        execute: {
          contract_addr: "<cw20 contract address>",
          msg,
          funds: [],
        },
      },
    },
  ],
});

```

### Stake native tokens

A staking message is a special type of message that isnt wrapped in the commin wasm.execute. It can have different types, here we expose as example the delegate staking.

```typescript
const {transactionHash, proposal} = await multisig.createProposal({
  from: "<sender address>",
  description: "<proposal description>",
  manualExecution: false,
  messages: [
    {
      staking: {
        delegate: {
          amount: {
            denom: "<network denom>",
            amount: "<amount>",
          },
          validator: validatorAddr,
        },
      },
    },
  ],
});
//TO WITHDRAW TOKENS, these can have a withdraw period depending on the network
//{
  //staking: {
    //undelegate: {
      //amount: {
        //denom: network.stakeCurrency.coinMinimalDenom,
        //amount: amount,
      //},
      //validator: validatorAddr,
    //},
  //},
//},
```

### Astrovault deposit

An example of contract interaction is the astrovault deposit, astrovault is an Automated Market Maker living on the archway blockchain.

```typescript
const amount = new BigNumber("<tokens amount>").multipliedBy(new BigNumber("1e18")).toString();
const msg = Buffer.from(
  JSON.stringify({
    deposit: {
      assets_amount: [amount, "0"],
      direct_staking: {},
    },
  })
).toString("base64");

const {proposal} = await multisig.createProposal({
  description: `Deposit ${amount} arch on astrovault`,
  from: userAddress,
  messages: [
    {
      wasm: {
        execute: {
          contract_addr: vault,
          msg,
          funds: [
            {
              amount,
              denom: network.stakeCurrency.coinMinimalDenom,
            },
          ],
        },
      },
    },
  ],
});
```

### Astrovault Withdraw

```typescript
const amount = new BigNumber("<withdraw amount>").multipliedBy(new BigNumber("1e18")).toString();
const msg = Buffer.from(
  JSON.stringify({
    withdrawal: {
      amount: new BigNumber(amount).div(new BigNumber("1e12")),
      direct_pool_withdrawal: {
        stable: {
          withdrawal_lockup_assets_amount: [amount, "0"],
          is_instant_withdrawal: true,
          to: contractAddress,
        },
      },
    },
  })
).toString("base64");

const {proposal} = await multisig.createProposal({
  description: `Deposit ${amount} arch on astrovault`,
  from: userAddress,
  messages: [
    {
      wasm: {
        execute: {
          contract_addr: pool,
          msg,
          funds: [],
        },
      },
    },
  ],
});

```


---

# 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:

```
GET https://nomos-docs.gitbook.io/nomos-1/readme/nomos-sdk/examples.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.
