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
| Parameter | Type | Description |
|---|---|---|
| events | string | Event filter (e.g., message.sender='rp1...') |
| pagination.limit | int | Max results |
| pagination.offset | int | Skip results |
| order_by | string | ORDER_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
| Mode | Description |
|---|---|
BROADCAST_MODE_SYNC | Wait for CheckTx |
BROADCAST_MODE_ASYNC | Return immediately |
BROADCAST_MODE_BLOCK | Wait 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:
| Event | Attributes |
|---|---|
transfer | recipient, sender, amount |
message | action, sender, module |
coin_spent | spender, amount |
coin_received | receiver, 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
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Internal error |
| 2 | Tx parsing error |
| 3 | Invalid sequence |
| 4 | Unauthorized |
| 5 | Insufficient funds |
| 11 | Out of gas |
| 13 | Insufficient 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}`);