TxEncode
curl --request POST \
--url https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode \
--header 'Content-Type: application/json' \
--data '
{
"tx": {
"body": {
"messages": [
{
"@type": "<string>"
}
],
"memo": "<string>",
"timeout_height": "<string>",
"unordered": true,
"timeout_timestamp": "2023-11-07T05:31:56Z",
"extension_options": [
{
"@type": "<string>"
}
],
"non_critical_extension_options": [
{
"@type": "<string>"
}
]
},
"auth_info": {
"signer_infos": [
{
"public_key": {
"@type": "<string>"
},
"mode_info": {
"single": {
"mode": "SIGN_MODE_UNSPECIFIED"
},
"multi": {
"bitarray": {
"extra_bits_stored": 123,
"elems": "aSDinaTvuI8gbWludGxpZnk="
},
"mode_infos": [
{}
]
}
},
"sequence": "<string>"
}
],
"fee": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"gas_limit": "<string>",
"payer": "<string>",
"granter": "<string>"
},
"tip": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"tipper": "<string>"
}
},
"signatures": [
"aSDinaTvuI8gbWludGxpZnk="
]
}
}
'import requests
url = "https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode"
payload = { "tx": {
"body": {
"messages": [{ "@type": "<string>" }],
"memo": "<string>",
"timeout_height": "<string>",
"unordered": True,
"timeout_timestamp": "2023-11-07T05:31:56Z",
"extension_options": [{ "@type": "<string>" }],
"non_critical_extension_options": [{ "@type": "<string>" }]
},
"auth_info": {
"signer_infos": [
{
"public_key": { "@type": "<string>" },
"mode_info": {
"single": { "mode": "SIGN_MODE_UNSPECIFIED" },
"multi": {
"bitarray": {
"extra_bits_stored": 123,
"elems": "aSDinaTvuI8gbWludGxpZnk="
},
"mode_infos": [{}]
}
},
"sequence": "<string>"
}
],
"fee": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"gas_limit": "<string>",
"payer": "<string>",
"granter": "<string>"
},
"tip": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"tipper": "<string>"
}
},
"signatures": ["aSDinaTvuI8gbWludGxpZnk="]
} }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
tx: {
body: JSON.stringify({
messages: [{'@type': '<string>'}],
memo: '<string>',
timeout_height: '<string>',
unordered: true,
timeout_timestamp: '2023-11-07T05:31:56Z',
extension_options: [{'@type': '<string>'}],
non_critical_extension_options: [{'@type': '<string>'}]
}),
auth_info: {
signer_infos: [
{
public_key: {'@type': '<string>'},
mode_info: {
single: {mode: 'SIGN_MODE_UNSPECIFIED'},
multi: {
bitarray: {extra_bits_stored: 123, elems: 'aSDinaTvuI8gbWludGxpZnk='},
mode_infos: [{}]
}
},
sequence: '<string>'
}
],
fee: {
amount: [{denom: '<string>', amount: '<string>'}],
gas_limit: '<string>',
payer: '<string>',
granter: '<string>'
},
tip: {amount: [{denom: '<string>', amount: '<string>'}], tipper: '<string>'}
},
signatures: ['aSDinaTvuI8gbWludGxpZnk=']
}
})
};
fetch('https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tx' => [
'body' => [
'messages' => [
[
'@type' => '<string>'
]
],
'memo' => '<string>',
'timeout_height' => '<string>',
'unordered' => true,
'timeout_timestamp' => '2023-11-07T05:31:56Z',
'extension_options' => [
[
'@type' => '<string>'
]
],
'non_critical_extension_options' => [
[
'@type' => '<string>'
]
]
],
'auth_info' => [
'signer_infos' => [
[
'public_key' => [
'@type' => '<string>'
],
'mode_info' => [
'single' => [
'mode' => 'SIGN_MODE_UNSPECIFIED'
],
'multi' => [
'bitarray' => [
'extra_bits_stored' => 123,
'elems' => 'aSDinaTvuI8gbWludGxpZnk='
],
'mode_infos' => [
[
]
]
]
],
'sequence' => '<string>'
]
],
'fee' => [
'amount' => [
[
'denom' => '<string>',
'amount' => '<string>'
]
],
'gas_limit' => '<string>',
'payer' => '<string>',
'granter' => '<string>'
],
'tip' => [
'amount' => [
[
'denom' => '<string>',
'amount' => '<string>'
]
],
'tipper' => '<string>'
]
],
'signatures' => [
'aSDinaTvuI8gbWludGxpZnk='
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode"
payload := strings.NewReader("{\n \"tx\": {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"memo\": \"<string>\",\n \"timeout_height\": \"<string>\",\n \"unordered\": true,\n \"timeout_timestamp\": \"2023-11-07T05:31:56Z\",\n \"extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"non_critical_extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ]\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"<string>\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_UNSPECIFIED\"\n },\n \"multi\": {\n \"bitarray\": {\n \"extra_bits_stored\": 123,\n \"elems\": \"aSDinaTvuI8gbWludGxpZnk=\"\n },\n \"mode_infos\": [\n {}\n ]\n }\n },\n \"sequence\": \"<string>\"\n }\n ],\n \"fee\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"gas_limit\": \"<string>\",\n \"payer\": \"<string>\",\n \"granter\": \"<string>\"\n },\n \"tip\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"tipper\": \"<string>\"\n }\n },\n \"signatures\": [\n \"aSDinaTvuI8gbWludGxpZnk=\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode")
.header("Content-Type", "application/json")
.body("{\n \"tx\": {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"memo\": \"<string>\",\n \"timeout_height\": \"<string>\",\n \"unordered\": true,\n \"timeout_timestamp\": \"2023-11-07T05:31:56Z\",\n \"extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"non_critical_extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ]\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"<string>\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_UNSPECIFIED\"\n },\n \"multi\": {\n \"bitarray\": {\n \"extra_bits_stored\": 123,\n \"elems\": \"aSDinaTvuI8gbWludGxpZnk=\"\n },\n \"mode_infos\": [\n {}\n ]\n }\n },\n \"sequence\": \"<string>\"\n }\n ],\n \"fee\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"gas_limit\": \"<string>\",\n \"payer\": \"<string>\",\n \"granter\": \"<string>\"\n },\n \"tip\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"tipper\": \"<string>\"\n }\n },\n \"signatures\": [\n \"aSDinaTvuI8gbWludGxpZnk=\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"tx\": {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"memo\": \"<string>\",\n \"timeout_height\": \"<string>\",\n \"unordered\": true,\n \"timeout_timestamp\": \"2023-11-07T05:31:56Z\",\n \"extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"non_critical_extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ]\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"<string>\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_UNSPECIFIED\"\n },\n \"multi\": {\n \"bitarray\": {\n \"extra_bits_stored\": 123,\n \"elems\": \"aSDinaTvuI8gbWludGxpZnk=\"\n },\n \"mode_infos\": [\n {}\n ]\n }\n },\n \"sequence\": \"<string>\"\n }\n ],\n \"fee\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"gas_limit\": \"<string>\",\n \"payer\": \"<string>\",\n \"granter\": \"<string>\"\n },\n \"tip\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"tipper\": \"<string>\"\n }\n },\n \"signatures\": [\n \"aSDinaTvuI8gbWludGxpZnk=\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"tx_bytes": "aSDinaTvuI8gbWludGxpZnk="
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}tx
TxEncode
gRPC: cosmos.tx.v1beta1.Service/TxEncode (reference)
TxEncode encodes the transaction.
POST
/
cosmos
/
tx
/
v1beta1
/
encode
TxEncode
curl --request POST \
--url https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode \
--header 'Content-Type: application/json' \
--data '
{
"tx": {
"body": {
"messages": [
{
"@type": "<string>"
}
],
"memo": "<string>",
"timeout_height": "<string>",
"unordered": true,
"timeout_timestamp": "2023-11-07T05:31:56Z",
"extension_options": [
{
"@type": "<string>"
}
],
"non_critical_extension_options": [
{
"@type": "<string>"
}
]
},
"auth_info": {
"signer_infos": [
{
"public_key": {
"@type": "<string>"
},
"mode_info": {
"single": {
"mode": "SIGN_MODE_UNSPECIFIED"
},
"multi": {
"bitarray": {
"extra_bits_stored": 123,
"elems": "aSDinaTvuI8gbWludGxpZnk="
},
"mode_infos": [
{}
]
}
},
"sequence": "<string>"
}
],
"fee": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"gas_limit": "<string>",
"payer": "<string>",
"granter": "<string>"
},
"tip": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"tipper": "<string>"
}
},
"signatures": [
"aSDinaTvuI8gbWludGxpZnk="
]
}
}
'import requests
url = "https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode"
payload = { "tx": {
"body": {
"messages": [{ "@type": "<string>" }],
"memo": "<string>",
"timeout_height": "<string>",
"unordered": True,
"timeout_timestamp": "2023-11-07T05:31:56Z",
"extension_options": [{ "@type": "<string>" }],
"non_critical_extension_options": [{ "@type": "<string>" }]
},
"auth_info": {
"signer_infos": [
{
"public_key": { "@type": "<string>" },
"mode_info": {
"single": { "mode": "SIGN_MODE_UNSPECIFIED" },
"multi": {
"bitarray": {
"extra_bits_stored": 123,
"elems": "aSDinaTvuI8gbWludGxpZnk="
},
"mode_infos": [{}]
}
},
"sequence": "<string>"
}
],
"fee": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"gas_limit": "<string>",
"payer": "<string>",
"granter": "<string>"
},
"tip": {
"amount": [
{
"denom": "<string>",
"amount": "<string>"
}
],
"tipper": "<string>"
}
},
"signatures": ["aSDinaTvuI8gbWludGxpZnk="]
} }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
tx: {
body: JSON.stringify({
messages: [{'@type': '<string>'}],
memo: '<string>',
timeout_height: '<string>',
unordered: true,
timeout_timestamp: '2023-11-07T05:31:56Z',
extension_options: [{'@type': '<string>'}],
non_critical_extension_options: [{'@type': '<string>'}]
}),
auth_info: {
signer_infos: [
{
public_key: {'@type': '<string>'},
mode_info: {
single: {mode: 'SIGN_MODE_UNSPECIFIED'},
multi: {
bitarray: {extra_bits_stored: 123, elems: 'aSDinaTvuI8gbWludGxpZnk='},
mode_infos: [{}]
}
},
sequence: '<string>'
}
],
fee: {
amount: [{denom: '<string>', amount: '<string>'}],
gas_limit: '<string>',
payer: '<string>',
granter: '<string>'
},
tip: {amount: [{denom: '<string>', amount: '<string>'}], tipper: '<string>'}
},
signatures: ['aSDinaTvuI8gbWludGxpZnk=']
}
})
};
fetch('https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'tx' => [
'body' => [
'messages' => [
[
'@type' => '<string>'
]
],
'memo' => '<string>',
'timeout_height' => '<string>',
'unordered' => true,
'timeout_timestamp' => '2023-11-07T05:31:56Z',
'extension_options' => [
[
'@type' => '<string>'
]
],
'non_critical_extension_options' => [
[
'@type' => '<string>'
]
]
],
'auth_info' => [
'signer_infos' => [
[
'public_key' => [
'@type' => '<string>'
],
'mode_info' => [
'single' => [
'mode' => 'SIGN_MODE_UNSPECIFIED'
],
'multi' => [
'bitarray' => [
'extra_bits_stored' => 123,
'elems' => 'aSDinaTvuI8gbWludGxpZnk='
],
'mode_infos' => [
[
]
]
]
],
'sequence' => '<string>'
]
],
'fee' => [
'amount' => [
[
'denom' => '<string>',
'amount' => '<string>'
]
],
'gas_limit' => '<string>',
'payer' => '<string>',
'granter' => '<string>'
],
'tip' => [
'amount' => [
[
'denom' => '<string>',
'amount' => '<string>'
]
],
'tipper' => '<string>'
]
],
'signatures' => [
'aSDinaTvuI8gbWludGxpZnk='
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode"
payload := strings.NewReader("{\n \"tx\": {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"memo\": \"<string>\",\n \"timeout_height\": \"<string>\",\n \"unordered\": true,\n \"timeout_timestamp\": \"2023-11-07T05:31:56Z\",\n \"extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"non_critical_extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ]\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"<string>\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_UNSPECIFIED\"\n },\n \"multi\": {\n \"bitarray\": {\n \"extra_bits_stored\": 123,\n \"elems\": \"aSDinaTvuI8gbWludGxpZnk=\"\n },\n \"mode_infos\": [\n {}\n ]\n }\n },\n \"sequence\": \"<string>\"\n }\n ],\n \"fee\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"gas_limit\": \"<string>\",\n \"payer\": \"<string>\",\n \"granter\": \"<string>\"\n },\n \"tip\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"tipper\": \"<string>\"\n }\n },\n \"signatures\": [\n \"aSDinaTvuI8gbWludGxpZnk=\"\n ]\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode")
.header("Content-Type", "application/json")
.body("{\n \"tx\": {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"memo\": \"<string>\",\n \"timeout_height\": \"<string>\",\n \"unordered\": true,\n \"timeout_timestamp\": \"2023-11-07T05:31:56Z\",\n \"extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"non_critical_extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ]\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"<string>\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_UNSPECIFIED\"\n },\n \"multi\": {\n \"bitarray\": {\n \"extra_bits_stored\": 123,\n \"elems\": \"aSDinaTvuI8gbWludGxpZnk=\"\n },\n \"mode_infos\": [\n {}\n ]\n }\n },\n \"sequence\": \"<string>\"\n }\n ],\n \"fee\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"gas_limit\": \"<string>\",\n \"payer\": \"<string>\",\n \"granter\": \"<string>\"\n },\n \"tip\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"tipper\": \"<string>\"\n }\n },\n \"signatures\": [\n \"aSDinaTvuI8gbWludGxpZnk=\"\n ]\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cosmos-rest.publicnode.com/cosmos/tx/v1beta1/encode")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"tx\": {\n \"body\": {\n \"messages\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"memo\": \"<string>\",\n \"timeout_height\": \"<string>\",\n \"unordered\": true,\n \"timeout_timestamp\": \"2023-11-07T05:31:56Z\",\n \"extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ],\n \"non_critical_extension_options\": [\n {\n \"@type\": \"<string>\"\n }\n ]\n },\n \"auth_info\": {\n \"signer_infos\": [\n {\n \"public_key\": {\n \"@type\": \"<string>\"\n },\n \"mode_info\": {\n \"single\": {\n \"mode\": \"SIGN_MODE_UNSPECIFIED\"\n },\n \"multi\": {\n \"bitarray\": {\n \"extra_bits_stored\": 123,\n \"elems\": \"aSDinaTvuI8gbWludGxpZnk=\"\n },\n \"mode_infos\": [\n {}\n ]\n }\n },\n \"sequence\": \"<string>\"\n }\n ],\n \"fee\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"gas_limit\": \"<string>\",\n \"payer\": \"<string>\",\n \"granter\": \"<string>\"\n },\n \"tip\": {\n \"amount\": [\n {\n \"denom\": \"<string>\",\n \"amount\": \"<string>\"\n }\n ],\n \"tipper\": \"<string>\"\n }\n },\n \"signatures\": [\n \"aSDinaTvuI8gbWludGxpZnk=\"\n ]\n }\n}"
response = http.request(request)
puts response.read_body{
"tx_bytes": "aSDinaTvuI8gbWludGxpZnk="
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Body
application/json
TxEncodeRequest is the request type for the Service.TxEncode RPC method.
TxEncodeRequest is the request type for the Service.TxEncode RPC method.
tx is the transaction to encode.
Show child attributes
Show child attributes
Response
A successful response.
TxEncodeResponse is the response type for the Service.TxEncode method.
tx_bytes is the encoded transaction bytes.
Was this page helpful?