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

adena.SignTx({
    messages: [
        {
            type: "string",
            value: object
        },
        // you may add additional messages within the brackets
        ...
    ],
    gasFee: number,
    gasWanted: number,
    memo?: string
})

Params

Key
Type
Description

message.type

string

"/bank.MsgSend" for transfers

"/vm.m_call" for contract calls "/vm.m_addpkg" for adding packages "/vm.m_run" for simulating transactions

message.value

object

Values (must match the type's format)

gasFee

number

Actual network fee to pay in ugnot

gasWanted

number

Gas limit

memo

string

Transaction memo (tag)

Response

Key
Type
Description

code

number

Account number

status

string

Returns success or failure

type

string

Response type

message

string

Descriptive message of the result

data

object

Encoded Transaction Model

Encoded Transaction Model

Key
Type
Description

encodedTransaction

string

Signed and encoded transaction

/bank.MsgSend

Sample Request

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
        }
    }],
    gasFee: 1,
    gasWanted: 1000000,
    memo: "12313"
  }
)

Sample Response

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

/vm.m_call

Sample Request

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"
        ]
      }
    }
  ], 
    gasFee: 1,
    gasWanted: 10000000
  }
)

Sample Response

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

/vm.m_addpkg

Sample Request

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
          }
        ]
      }
    }
  }],
  gasFee: 1, 
  gasWanted: 2000000
});

Sample Response

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

/vm.m_run

Sample Request

await adena.SignTx({
  messages: [{
    type: "/vm.m_run",
    value: {
      caller: "g1jg8mtutu9khhfwc4nxmuhcpftf0pajdhfvsqf5",
      send: "",
      package: {
        name: "main",
        path: "gno.land/r/demo/main",
        files: [
          {
            name: "script.gno",
            body: "package main\n\nfunc Main() {\n\tprintln(\"HELLO WORLD\")\n}",
          }
        ]
      }
    }
  }],
  gasFee: 1, 
  gasWanted: 2000000
});

Sample Response

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

Last updated