{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-products/wallet/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"type":"markdown"},"seo":{"title":"Transaction encoding formats","description":"User guides, API reference, and support resources.","siteUrl":"https://docs.ripple.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"transaction-encoding-formats","__idx":0},"children":["Transaction encoding formats"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When you use the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/wallet/transactions/raw-signing"},"children":["raw transaction API"]},", the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," field must be encoded in a blockchain-specific format. This page details the exact encoding requirements for each supported blockchain."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The API decodes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," when you submit it. A payload it can't decode returns HTTP 400 and creates no transaction: on an EVM wallet, the message is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid encoded transaction"]}," with the reason ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PAL010.011"]},", and on an XRP Ledger wallet, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["xrp ledger orchestrator rejected the transaction"]}," with the reason ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PAL010.022"]},". A request without ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," returns HTTP 400 with the reason ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["PAL000.020"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"evm-chains-ethereum-base-polygon-avalanche-arbitrum-bnb-chain","__idx":1},"children":["EVM chains (Ethereum, Base, Polygon, Avalanche, Arbitrum, BNB Chain)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," field must match the output of go-ethereum's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rlp.EncodeToBytes(types.Transaction)"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Format:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"RLP(type_byte || RLP([chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gas, to, value, data, accessList, v, r, s]))\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Key requirements:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Include v, r, s signature fields"]}," — Set to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0"]}," for unsigned transactions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Apply outer RLP wrapper"]}," — The typed transaction must be wrapped as an RLP byte string"]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Common error"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you receive ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["\"typed transaction too short\""]},", you're likely using the standard unsigned format (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0x02 || RLP([9 fields])"]},") which is missing the v/r/s placeholders and outer RLP wrapper."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from eth_account.typed_transactions import DynamicFeeTransaction\nimport rlp\n\n# Use the signed transaction serializer (includes v, r, s fields)\nserializer = DynamicFeeTransaction._signed_transaction_serializer\n\ntx = serializer(\n    chainId=84532,  # Base Sepolia\n    nonce=nonce,\n    maxPriorityFeePerGas=max_priority,\n    maxFeePerGas=max_fee,\n    gas=gas_limit,\n    to=bytes.fromhex(to_address[2:]),\n    value=0,\n    data=calldata_bytes,\n    accessList=(),\n    v=0,  # Placeholder for unsigned\n    r=0,  # Placeholder for unsigned\n    s=0,  # Placeholder for unsigned\n)\n\n# RLP encode the fields\ntx_rlp = rlp.encode(tx)\n\n# Add EIP-1559 type prefix (0x02)\ntyped_tx = bytes([2]) + tx_rlp\n\n# Wrap in RLP string (matches go-ethereum's rlp.EncodeToBytes)\nencoded_transaction = rlp.encode(typed_tx).hex()\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Go example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"import (\n    \"github.com/ethereum/go-ethereum/core/types\"\n    \"github.com/ethereum/go-ethereum/rlp\"\n)\n\ntx := types.NewTx(&types.DynamicFeeTx{\n    ChainID:   big.NewInt(84532),\n    Nonce:     nonce,\n    GasTipCap: maxPriorityFeePerGas,\n    GasFeeCap: maxFeePerGas,\n    Gas:       gasLimit,\n    To:        &toAddress,\n    Value:     big.NewInt(0),\n    Data:      calldata,\n})\n\nencodedBytes, _ := rlp.EncodeToBytes(tx)\nencodedTransaction := hex.EncodeToString(encodedBytes)\n","lang":"go"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"xrp-ledger","__idx":2},"children":["XRP Ledger"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," field must be an ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["XRP Binary Codec signing payload"]},": the output of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodeForSigning"]}," for single-signing, or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodeForMultisigning"]}," for multi-signing. Only these payloads produce valid signatures. The platform checks the signing prefix after it signs, and fails a transaction whose payload has neither prefix."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Format:"]}," Hex-encoded binary codec signing payload of the transaction JSON"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Key requirements:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For single-signed transactions, set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SigningPubKey"]}," to the wallet's public key"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodeForSigning"]}," (not ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encode"]},") for unsigned transactions"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For multi-signed transactions, use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodeForMultisigning"]}," with the signer's address, leave ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SigningPubKey"]}," empty, and set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["signOnly: true"]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"encode() output fails"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ripple Custody (Wallet) signs exactly the bytes you submit. XRPL verifies each signature against a signing payload that starts with a 4-byte prefix: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodeForSigning"]}," prepends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["53545800"]}," (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["STX\\0"]},") for single-signing, and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodeForMultisigning"]}," prepends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["534D5400"]}," (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SMT\\0"]},") for multi-signing. Plain ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encode"]}," adds neither. If you submit ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encode"]}," output, the request returns HTTP 200, but the transaction ends in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FAILED"]}," with the reason ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SignProcessor: unsupported signing payload prefix"]},". A multi-signing payload (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["534D5400"]},") submitted with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["signOnly: false"]}," also ends in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["FAILED"]},", because the platform can't submit a multi-signed transaction."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Quick check: confirm that your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," hex starts with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["53545800"]}," (single-sign) or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["534D5400"]}," (multi-sign)."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Multi-signing:"]}," Build the transaction's ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Signers"]}," array from the returned ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["canonicalSignature"]},". The platform assembles single-signed blobs only, so for a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["534D5400"]}," payload the response carries ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["canonicalSignature"]}," but no ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["signedTransaction"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["hash"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JavaScript example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const { encodeForSigning } = require('ripple-binary-codec');\n\nconst tx = {\n    Account: \"rSourceAddress...\",\n    Destination: \"rDestAddress...\",\n    Amount: \"1000000\",  // In drops\n    Fee: \"10\",\n    Sequence: 12345,\n    SigningPubKey: \"02ECE63017B0FEFC...\",  // Required\n    TransactionType: \"Payment\"\n};\n\nconst encodedTransaction = encodeForSigning(tx);\n\n// For multi-signed transactions, set SigningPubKey to \"\" and pass the signer's address:\n// const encodedTransaction = encodeForMultisigning({ ...tx, SigningPubKey: \"\" }, signerAddress);\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from xrpl.core.binarycodec import encode_for_signing\n\ntx = {\n    \"Account\": \"rSourceAddress...\",\n    \"Destination\": \"rDestAddress...\",\n    \"Amount\": \"1000000\",\n    \"Fee\": \"10\",\n    \"Sequence\": 12345,\n    \"SigningPubKey\": \"02ECE63017B0FEFC...\",\n    \"TransactionType\": \"Payment\"\n}\n\nencoded_transaction = encode_for_signing(tx)\n\n# For multi-signed transactions, set SigningPubKey to \"\" and pass the signer's address:\n# encoded_transaction = encode_for_multisigning({**tx, \"SigningPubKey\": \"\"}, signer_address)\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Java example (xrpl4j):"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"java","header":{"controls":{"copy":{}}},"source":"import org.xrpl.xrpl4j.codec.binary.XrplBinaryCodec;\n\nXrplBinaryCodec codec = XrplBinaryCodec.getInstance();\n\nString txJson = \"\"\"\n    {\n      \"Account\": \"rSourceAddress...\",\n      \"Destination\": \"rDestAddress...\",\n      \"Amount\": \"1000000\",\n      \"Fee\": \"10\",\n      \"Sequence\": 12345,\n      \"SigningPubKey\": \"02ECE63017B0FEFC...\",\n      \"TransactionType\": \"Payment\"\n    }\n    \"\"\";\n\n// Single-signing: prepends 53545800\nString encodedTransaction = codec.encodeForSigning(txJson);\n\n// For multi-signed transactions, pass the signer's address\n// (and leave SigningPubKey empty in the transaction JSON):\n// String encodedTransaction = codec.encodeForMultiSigning(txJson, signerAddress);\n","lang":"java"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"solana","__idx":3},"children":["Solana"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," field must be a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["base64-encoded"]}," serialized Solana transaction."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Format:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["base64(transaction.MarshalBinary())"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Key requirements:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Transaction must include a valid recent blockhash"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Account keys must be properly ordered (fee payer first)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use standard base64 encoding (not base58)"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"from solders.transaction import Transaction\nfrom solders.message import Message\nimport base64\n\n# Build your transaction message\nmessage = Message.new_with_blockhash(\n    instructions,\n    payer,\n    blockhash\n)\n\n# Create unsigned transaction\ntx = Transaction.new_unsigned(message)\n\n# Serialize and base64 encode\ntx_bytes = bytes(tx)\nencoded_transaction = base64.b64encode(tx_bytes).decode('utf-8')\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JavaScript example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const { Transaction } = require('@solana/web3.js');\n\nconst tx = new Transaction();\ntx.recentBlockhash = blockhash;\ntx.feePayer = payerPublicKey;\ntx.add(instruction);\n\n// Serialize (without signing)\nconst serialized = tx.serialize({ requireAllSignatures: false });\nconst encodedTransaction = serialized.toString('base64');\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"tron","__idx":4},"children":["TRON"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," field must be a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["hex-encoded"]}," TRON Transaction protobuf."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Format:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["hex(proto.Marshal(Transaction))"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Key requirements:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Transaction must include valid ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ref_block_bytes"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ref_block_hash"]}," from a recent block"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Expiration timestamp must be in the future (typically current time + 60 seconds, in milliseconds)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Fee limit must be set for TRC-20 transfers (recommended: 15,000,000 SUN = 15 TRX)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["The signing hash is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SHA256(raw_data)"]}," — Ripple Custody (Wallet) computes this automatically"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Supported contract types:"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Contract Type"},"children":["Contract Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TransferContract"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Native TRX transfers"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["TriggerSmartContract"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["TRC-20 token transfers and smart contract calls"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python example (using the TRON HTTP API):"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\n\n# Build a TRX transfer transaction\ntx = requests.post(\n    \"https://api.shasta.trongrid.io/wallet/createtransaction\",  # or mainnet\n    json={\n        \"owner_address\": \"TSourceAddress...\",\n        \"to_address\": \"TDestAddress...\",\n        \"amount\": 1_000_000,  # 1 TRX in SUN\n        \"visible\": True,\n    },\n).json()\n\n# raw_data_hex is only the raw_data message. Wrap it as field 1 of a\n# Transaction protobuf: tag 0x0a, varint length, then the raw_data bytes.\nraw = bytes.fromhex(tx[\"raw_data_hex\"])\nlength, n = b\"\", len(raw)\nwhile n >= 0x80:\n    length += bytes([(n & 0x7F) | 0x80])\n    n >>= 7\nlength += bytes([n])\n\nencoded_transaction = (b\"\\x0a\" + length + raw).hex()\n\n# For TRC-20 transfers, use wallet/triggersmartcontract instead\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["JavaScript example (using TronWeb):"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"const TronWeb = require('tronweb');\n\nconst tronWeb = new TronWeb({\n    fullHost: 'https://api.shasta.trongrid.io',  // or mainnet\n});\n\n// Build a TRX transfer transaction\nconst tx = await tronWeb.transactionBuilder.sendTrx(\n    'TDestAddress...',      // to\n    1000000,                // amount in SUN (1 TRX)\n    'TSourceAddress...'     // from\n);\n\n// raw_data_hex is only the raw_data message. Wrap it as field 1 of a\n// Transaction protobuf: tag 0x0a, varint length, then the raw_data bytes.\nconst raw = Buffer.from(tx.raw_data_hex, 'hex');\nconst length = [];\nfor (let n = raw.length; ; n >>>= 7) {\n    if (n < 0x80) { length.push(n); break; }\n    length.push((n & 0x7f) | 0x80);\n}\n\nconst encodedTransaction = Buffer.concat([Buffer.from([0x0a, ...length]), raw]).toString('hex');\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Go example:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"go","header":{"controls":{"copy":{}}},"source":"import (\n    \"encoding/hex\"\n    \"time\"\n    \n    \"github.com/fbsobreira/gotron-sdk/pkg/proto/core\"\n    \"google.golang.org/protobuf/proto\"\n    \"google.golang.org/protobuf/types/known/anypb\"\n)\n\n// Build a TRX transfer\ntransfer := &core.TransferContract{\n    OwnerAddress: ownerAddrBytes,  // 21-byte TRON address\n    ToAddress:    toAddrBytes,\n    Amount:       1000000,         // 1 TRX in SUN\n}\n\nanyValue, _ := anypb.New(transfer)\n\ntx := &core.Transaction{\n    RawData: &core.TransactionRaw{\n        Contract: []*core.Transaction_Contract{{\n            Type:      core.Transaction_Contract_TransferContract,\n            Parameter: anyValue,\n        }},\n        RefBlockBytes: refBlockBytes,  // From recent block\n        RefBlockHash:  refBlockHash,\n        Expiration:    time.Now().Add(60*time.Second).UnixMilli(),\n        Timestamp:     time.Now().UnixMilli(),\n    },\n}\n\ntxBytes, _ := proto.Marshal(tx)\nencodedTransaction := hex.EncodeToString(txBytes)\n","lang":"go"},"children":[]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"TRON address format"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TRON addresses can be in base58 format (starts with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["T"]},") or hex format (starts with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["41"]},"). The API accepts base58 addresses, but internally they are converted to 21-byte hex addresses in the protobuf."]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Reference block requirements"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["TRON transactions require ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ref_block_bytes"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ref_block_hash"]}," from a recent block (within ~18 hours). If you're building transactions manually, fetch the latest block and extract bytes 6-8 of the block number and bytes 8-16 of the block hash."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1money","__idx":5},"children":["1Money"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["encodedTransaction"]}," field must be a ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["hex-encoded JSON object"]}," with a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionType"]}," and a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payload"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Format:"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["hex(JSON({ transactionType, payload }))"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\n  \"transactionType\": \"TokenMint\",\n  \"payload\": {\n    \"chain_id\": 1212101,\n    \"nonce\": 0,\n    \"recipient\": \"0x...\",\n    \"value\": 1000000000000000000,\n    \"token\": \"0x...\"\n  }\n}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Key requirements:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["transactionType"]}," to one of the supported transaction types. (See"," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/wallet/transactions/raw-signing/1money-transaction-types"},"children":["1Money transaction types"]},".)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Include the 1Money ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["chain_id"]}," in every payload"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["nonce"]}," to the wallet's current sequence, from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["GET /v2/vaults/{vaultId}/wallets/{walletId}/sequence"]},". (See"," ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/wallet/transactions/raw-signing/1money-transaction-types#example-mint-tokens"},"children":["Example: mint tokens"]},".)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Use snake_case payload field names, as shown in the examples."]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Payload shapes vary by transaction type"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The envelope is the same for every 1Money transaction, but the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payload"]}," fields differ."," ","Check ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/products/wallet/transactions/raw-signing/1money-transaction-types"},"children":["1Money transaction types"]}," before encoding — several"," ","types share a shape, and a few (notably ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["BatchPayment"]},") don't."]}]}]},"headings":[{"value":"Transaction encoding formats","id":"transaction-encoding-formats","depth":1},{"value":"EVM chains (Ethereum, Base, Polygon, Avalanche, Arbitrum, BNB Chain)","id":"evm-chains-ethereum-base-polygon-avalanche-arbitrum-bnb-chain","depth":2},{"value":"XRP Ledger","id":"xrp-ledger","depth":2},{"value":"Solana","id":"solana","depth":2},{"value":"TRON","id":"tron","depth":2},{"value":"1Money","id":"1money","depth":2}],"frontmatter":{"title":"Transaction encoding formats","seo":{"title":"Transaction encoding formats"}},"lastModified":"2026-10-08T12:52:04.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/products/wallet/transactions/raw-signing/encoding-formats","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}