Skip to main content

Transaction API

REST endpoints for querying and submitting transactions.

Get Transaction

GET /cosmos/tx/v1beta1/txs/{hash}

Response

{
"tx": {
"body": {
"messages": [...],
"memo": "",
"timeout_height": "0"
},
"auth_info": {...},
"signatures": [...]
},
"tx_response": {
"height": "12345",
"txhash": "ABC123...",
"codespace": "",
"code": 0,
"data": "...",
"raw_log": "...",
"logs": [...],
"info": "",
"gas_wanted": "200000",
"gas_used": "150000",
"tx": {...},
"timestamp": "2024-01-15T10:30:00Z"
}
}

Search Transactions

GET /cosmos/tx/v1beta1/txs

Query Parameters

ParameterTypeDescription
eventsstringEvent filter (e.g., message.sender='rp1...')
pagination.limitintMax results
pagination.offsetintSkip results
order_bystringORDER_BY_ASC or ORDER_BY_DESC

Example

# Get transactions by sender
curl "https://api.rp.one/cosmos/tx/v1beta1/txs?events=message.sender='rp1abc...'"

# Get transfers to address
curl "https://api.rp.one/cosmos/tx/v1beta1/txs?events=transfer.recipient='rp1xyz...'"

Broadcast Transaction

POST /cosmos/tx/v1beta1/txs

Request Body

{
"tx_bytes": "base64_encoded_tx",
"mode": "BROADCAST_MODE_SYNC"
}

Broadcast Modes

ModeDescription
BROADCAST_MODE_SYNCWait for CheckTx
BROADCAST_MODE_ASYNCReturn immediately
BROADCAST_MODE_BLOCKWait for block inclusion

Response

{
"tx_response": {
"height": "0",
"txhash": "ABC123...",
"codespace": "",
"code": 0,
"data": "",
"raw_log": "[]",
"logs": [],
"info": "",
"gas_wanted": "0",
"gas_used": "0"
}
}

Simulate Transaction

POST /cosmos/tx/v1beta1/simulate

Estimate gas without broadcasting.

Request

{
"tx_bytes": "base64_encoded_tx"
}

Response

{
"gas_info": {
"gas_wanted": "200000",
"gas_used": "150000"
},
"result": {
"data": "...",
"log": "...",
"events": [...]
}
}

Bank Transactions

Send Tokens

POST /cosmos/tx/v1beta1/txs

Message type: cosmos.bank.v1beta1.MsgSend

{
"body": {
"messages": [
{
"@type": "/cosmos.bank.v1beta1.MsgSend",
"from_address": "rp1sender...",
"to_address": "rp1recipient...",
"amount": [
{
"denom": "urp1",
"amount": "1000000"
}
]
}
]
}
}

Multi-Send

{
"@type": "/cosmos.bank.v1beta1.MsgMultiSend",
"inputs": [
{
"address": "rp1sender...",
"coins": [{"denom": "urp1", "amount": "3000000"}]
}
],
"outputs": [
{
"address": "rp1recipient1...",
"coins": [{"denom": "urp1", "amount": "1000000"}]
},
{
"address": "rp1recipient2...",
"coins": [{"denom": "urp1", "amount": "2000000"}]
}
]
}

Transaction Events

Common event types:

EventAttributes
transferrecipient, sender, amount
messageaction, sender, module
coin_spentspender, amount
coin_receivedreceiver, amount

Filtering by Events

# By sender
events=message.sender='rp1...'

# By module
events=message.module='privacy'

# Multiple conditions
events=message.sender='rp1...'&events=message.action='/rp1.privacy.v1.MsgShield'

Error Codes

CodeDescription
0Success
1Internal error
2Tx parsing error
3Invalid sequence
4Unauthorized
5Insufficient funds
11Out of gas
13Insufficient fee

TypeScript Example

import { RP1Client } from '@rp1/sdk';

const client = new RP1Client('https://api.rp.one');

// Get transaction
const tx = await client.getTx('TXHASH...');
console.log(`Status: ${tx.code === 0 ? 'Success' : 'Failed'}`);
console.log(`Gas Used: ${tx.gasUsed}`);

// Search transactions
const txs = await client.searchTxs({
sender: 'rp1abc...',
limit: 10,
});

// Broadcast transaction
const result = await client.broadcastTx(signedTx, 'sync');
console.log(`TX Hash: ${result.txhash}`);

Next Steps