# Sign a Transaction

A web application may also request Adena to **create a signed transaction** via the `adena.SignTx` method. Upon receiving the request, Adena will prompt the user to sign the transaction.

If the user proceeds to sign the transaction, Adena will return the encoded transaction data on the console.

#### Code

```javascript
adena.SignTx(
    tx: {
        messages: [
            {
                type: "string",
                value: object
            },
            // you may add additional messages within the brackets
            ...
        ],
        memo?: string
    }, 
    isNotification?: boolean // default: true
)
```

#### **Params**

<table><thead><tr><th width="188">Key</th><th width="197.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>message.type</code></td><td><code>string</code></td><td><p><code>"/bank.MsgSend"</code> for transfers</p><p><code>"/vm.m_call"</code> for contract calls<br><code>"/vm.m_addpkg"</code> for adding packages<br><code>"/vm.m_run"</code> for simulating transactions</p></td></tr><tr><td><code>message.value</code></td><td><code>object</code></td><td>Values (must match the type's format)</td></tr><tr><td><code>memo</code></td><td><code>string</code></td><td>Transaction memo (tag)</td></tr><tr><td><code>tx</code></td><td><code>[Transaction Model]</code></td><td>Transaction info</td></tr><tr><td><code>isNotification</code></td><td><code>boolean</code></td><td>Notification (default: true)</td></tr></tbody></table>

#### Response

<table><thead><tr><th width="212">Key</th><th width="168.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>code</code></td><td><code>number</code></td><td>Account number</td></tr><tr><td><code>status</code></td><td><code>string</code></td><td>Returns <code>success</code> or <code>failure</code></td></tr><tr><td><code>type</code></td><td><code>string</code></td><td>Response type</td></tr><tr><td><code>message</code></td><td><code>string</code></td><td>Descriptive message of the result</td></tr><tr><td><code>data</code></td><td><code>object</code></td><td><strong>Encoded Transaction Model</strong></td></tr></tbody></table>

#### Transaction Model

<table><thead><tr><th width="212">Key</th><th width="168.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>messages[].type</code></td><td><code>string</code></td><td>"/bank.MsgSend" for transfers<br>"/vm.m_call" for contract calls<br>"/vm.m_addpkg" for adding packages<br>"/vm.m_run" for executing a gno script</td></tr><tr><td><code>messages[].value</code></td><td><code>object</code></td><td>Values (must match the type's format)</td></tr><tr><td><code>memo</code></td><td><code>String</code></td><td>Transaction memo (tag)</td></tr></tbody></table>

#### Encoded Transaction Model

<table><thead><tr><th width="236">Key</th><th width="168.33333333333331">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>encodedTransaction</code></td><td><code>string</code></td><td>Signed and encoded transaction</td></tr></tbody></table>

### `/bank.MsgSend`

#### Sample Request

```javascript
await adena.SignTx(
  {
    messages: [{
        type: "/bank.MsgSend",
        value: {
            from_address: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", // your address
            to_address: "g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae", // recipient's address
            amount: "5000000ugnot" // sending amount. 1GNOT = 1000000ugnot
        }
    }],
    memo: "12313"
  }
)
```

#### Sample Response

```json
{
    code: 0,
    type: "SIGN_TX",
    status: "success",
    message: "Sign Transaction",
    data: {
        encodedTransaction: "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90EgwIgIl6EgYxdWdub3Qafgo6ChMvdG0uUHViS2V5U2VjcDI1NmsxEiMKIQPhYTbbFx4y30iZNZQfBW4i+Jhj43OdCrfNSexCg5ydshJAK3y9vuIO0BhY+P6f361/RP5QNFPCpHiaNE/cGhRyOV4MSDSl+++WN56NKefZF27MQTHu3lFDTZ7pPTTbkn7DeCIFMTIzMTM="
    },
}
```

### `/vm.m_call`

#### Sample Request

```javascript
await adena.SignTx(
  {
    messages: [{
      type: "/vm.m_call",
      value: {
        caller: "g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae", // your Adena address
        send: "",
        pkg_path: "gno.land/r/demo/foo20", // Gnoland package path
        func: "Transfer", // Function name
        args: [ // Arguments
          "g122n67es9vzs0rmharsggfr4sdkd45aysnuzf7m",
          "1"
        ]
      }
    }
  ], 
  }
)
```

#### Sample Response

```json
{
    code: 0,
    type: "SIGN_TX",
    status: "success",
    message: "Sign Transaction",
    data: {
        encodedTransaction: "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90EgwIgIl6EgYxdWdub3Qafgo6ChMvdG0uUHViS2V5U2VjcDI1NmsxEiMKIQPhYTbbFx4y30iZNZQfBW4i+Jhj43OdCrfNSexCg5ydshJAK3y9vuIO0BhY+P6f361/RP5QNFPCpHiaNE/cGhRyOV4MSDSl+++WN56NKefZF27MQTHu3lFDTZ7pPTTbkn7DeCIFMTIzMTM="
    },
}
```

### `/vm.m_addpkg`

#### Sample Request

```javascript
await adena.SignTx({
  messages: [{
    type: "/vm.m_addpkg",
    value: {
      creator: "g1ffzxha57dh0qgv9ma5v393ur0zexfvp6lsjpae", // your Adena address
      deposit: "1ugnot", // amount of ugnot to deposit in the package (enter a blank or an amount above 1 ugnot)
      package: {
        name: "hello", // package name
        path: "gno.land/r/demo/hello", // package path (cannot be a duplicate from existing paths on Gnoland)
        files: [ // a list of files to deploy
          {
            name: "hello.gno", // file name
            body: "package hello\n\nfunc Hello() string {\n\treturn \"Hello() called\"\n}\n\nfunc Render() string {\n\treturn \"Render() called\"\n}", //file contents
          }
        ]
      }
    }
  }],
});
```

#### Sample Response

```json
{
    code: 0,
    type: "SIGN_TX",
    status: "success",
    message: "Sign Transaction",
    data: {
        encodedTransaction: "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90EgwIgIl6EgYxdWdub3Qafgo6ChMvdG0uUHViS2V5U2VjcDI1NmsxEiMKIQPhYTbbFx4y30iZNZQfBW4i+Jhj43OdCrfNSexCg5ydshJAK3y9vuIO0BhY+P6f361/RP5QNFPCpHiaNE/cGhRyOV4MSDSl+++WN56NKefZF27MQTHu3lFDTZ7pPTTbkn7DeCIFMTIzMTM="
    },
}
```

### `/vm.m_run`

#### Sample Request

```javascript
await adena.SignTx({
  messages: [{
    type: "/vm.m_run",
    value: {
      caller: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5", // your Adena address
      send: "", // amount of ugnot to send
      package: {
        name: "main", // package name
        path: "", // msg_run is empty path
        files: [
          {
            name: "main.gno", // file name
            body: "package main\n\nfunc main() {\n\tprintln(\"HELLO WORLD\")\n}", // file content (msg_run has main function)
          }
        ]
      }
    }
  }]
});
```

#### Sample Response

```json
{
    code: 0,
    type: "SIGN_TX",
    status: "success",
    message: "Sign Transaction",
    data: {
        encodedTransaction: "CnMKDS9iYW5rLk1zZ1NlbmQSYgooZzFqZzhtdHV0dTlraGhmd2M0bnhtdWhjcGZ0ZjBwYWpkaGZ2c3FmNRIoZzFmZnp4aGE1N2RoMHFndjltYTV2MzkzdXIwemV4ZnZwNmxzanBhZRoMNTAwMDAwMHVnbm90EgwIgIl6EgYxdWdub3Qafgo6ChMvdG0uUHViS2V5U2VjcDI1NmsxEiMKIQPhYTbbFx4y30iZNZQfBW4i+Jhj43OdCrfNSexCg5ydshJAK3y9vuIO0BhY+P6f361/RP5QNFPCpHiaNE/cGhRyOV4MSDSl+++WN56NKefZF27MQTHu3lFDTZ7pPTTbkn7DeCIFMTIzMTM="
    },
}
```


---

# 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.adena.app/integrations/transactions/sign-a-transaction.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.
