or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

accounts.mdclients.mdcore.mdindex.mdledger.mdmodels.mdtransactions.mdutils.mdwallets.md

transactions.mddocs/

0

# Transaction Management

1

2

Create, sign, submit, and manage XRPL transactions with full support for all transaction types including payments, offers, escrows, NFTs, AMM operations, and cross-chain bridges. The transaction module provides the complete lifecycle management for XRPL transactions.

3

4

## Capabilities

5

6

### Transaction Signing

7

8

Sign transactions with wallets using single or multisign approaches.

9

10

```python { .api }

11

from xrpl import transaction

12

13

def sign(transaction, wallet, multisign: bool = False):

14

"""

15

Sign a transaction with a wallet.

16

17

Args:

18

transaction: Transaction object to sign

19

wallet: Wallet object containing private key

20

multisign: Whether to create a multisign signature

21

22

Returns:

23

Signed transaction object with signature

24

"""

25

26

def multisign(transaction, wallet):

27

"""

28

Add a multisign signature to a transaction.

29

30

Args:

31

transaction: Transaction object to multisign

32

wallet: Wallet object for signing

33

34

Returns:

35

Transaction with added multisign signature

36

"""

37

```

38

39

### Transaction Submission

40

41

Submit transactions to the XRPL network with various submission strategies.

42

43

```python { .api }

44

def submit(transaction, client, fail_hard: bool = False):

45

"""

46

Submit a signed transaction to the network.

47

48

Args:

49

transaction: Signed transaction object

50

client: XRPL client for network communication

51

fail_hard: Whether to fail hard on submission errors

52

53

Returns:

54

Submission response from the network

55

"""

56

57

def submit_and_wait(

58

transaction,

59

client,

60

wallet,

61

autofill: bool = True,

62

check_fee: bool = True

63

):

64

"""

65

Sign, submit, and wait for transaction validation.

66

67

Args:

68

transaction: Transaction object to submit

69

client: XRPL client for network communication

70

wallet: Wallet for signing

71

autofill: Whether to auto-populate transaction fields

72

check_fee: Whether to validate transaction fee

73

74

Returns:

75

Final transaction result after validation

76

"""

77

78

def sign_and_submit(

79

transaction,

80

client,

81

wallet,

82

autofill: bool = True,

83

check_fee: bool = True

84

):

85

"""

86

Sign and submit a transaction in one operation.

87

88

Args:

89

transaction: Transaction object to submit

90

client: XRPL client for network communication

91

wallet: Wallet for signing

92

autofill: Whether to auto-populate transaction fields

93

check_fee: Whether to validate transaction fee

94

95

Returns:

96

Submission response from the network

97

"""

98

```

99

100

### Transaction Preparation

101

102

Automatically populate transaction fields and validate transactions before submission.

103

104

```python { .api }

105

def autofill(transaction, client):

106

"""

107

Auto-populate transaction fields like sequence, fee, and last ledger sequence.

108

109

Args:

110

transaction: Transaction object to autofill

111

client: XRPL client for fetching current ledger info

112

113

Returns:

114

Transaction with populated fields

115

"""

116

117

def autofill_and_sign(transaction, client, wallet):

118

"""

119

Autofill transaction fields and sign in one operation.

120

121

Args:

122

transaction: Transaction object to prepare

123

client: XRPL client for network communication

124

wallet: Wallet for signing

125

126

Returns:

127

Signed transaction with autofilled fields

128

"""

129

```

130

131

### Transaction Simulation and Analysis

132

133

Test transactions and analyze their effects before submission.

134

135

```python { .api }

136

def simulate(transaction, client):

137

"""

138

Simulate transaction execution without submitting to ledger.

139

140

Args:

141

transaction: Transaction object to simulate

142

client: XRPL client for simulation

143

144

Returns:

145

Simulation results showing expected effects

146

"""

147

148

def transaction_json_to_binary_codec_form(txn_json: dict) -> dict:

149

"""

150

Convert transaction JSON to binary codec form.

151

152

Args:

153

txn_json: Transaction as JSON dictionary

154

155

Returns:

156

Transaction in binary codec format

157

"""

158

```

159

160

### Batch Operations

161

162

Handle multiple transactions and batch signing operations.

163

164

```python { .api }

165

def sign_multiaccount_batch(batch_txns: list, wallet):

166

"""

167

Sign a batch of transactions with one wallet.

168

169

Args:

170

batch_txns: List of transaction objects to sign

171

wallet: Wallet for signing all transactions

172

173

Returns:

174

List of signed transactions

175

"""

176

177

def combine_batch_signers(batch_signers: list) -> list:

178

"""

179

Combine multiple batch signer arrays.

180

181

Args:

182

batch_signers: List of signer arrays to combine

183

184

Returns:

185

Combined list of signers

186

"""

187

```

188

189

## Common Transaction Types

190

191

### Payment Transactions

192

193

```python { .api }

194

from xrpl.models.transactions import Payment

195

from xrpl.models.amounts import IssuedCurrencyAmount

196

197

# XRP payment

198

payment = Payment(

199

account="rSender...",

200

destination="rReceiver...",

201

amount="1000000" # 1 XRP in drops

202

)

203

204

# Issued currency payment

205

payment = Payment(

206

account="rSender...",

207

destination="rReceiver...",

208

amount=IssuedCurrencyAmount(

209

currency="USD",

210

value="100.50",

211

issuer="rIssuer..."

212

)

213

)

214

```

215

216

### Offer Transactions

217

218

```python { .api }

219

from xrpl.models.transactions import OfferCreate, OfferCancel

220

221

# Create a currency exchange offer

222

offer = OfferCreate(

223

account="rTrader...",

224

taker_gets="1000000", # 1 XRP

225

taker_pays=IssuedCurrencyAmount(

226

currency="USD",

227

value="0.50",

228

issuer="rIssuer..."

229

)

230

)

231

232

# Cancel an existing offer

233

cancel = OfferCancel(

234

account="rTrader...",

235

offer_sequence=12345

236

)

237

```

238

239

### Trust Line Transactions

240

241

```python { .api }

242

from xrpl.models.transactions import TrustSet

243

from xrpl.models.currencies import IssuedCurrency

244

245

# Create/modify a trust line

246

trust_set = TrustSet(

247

account="rAccount...",

248

limit_amount=IssuedCurrencyAmount(

249

currency="USD",

250

value="1000",

251

issuer="rIssuer..."

252

)

253

)

254

```

255

256

## Usage Examples

257

258

### Basic Transaction Workflow

259

260

```python

261

from xrpl.clients import JsonRpcClient

262

from xrpl.wallet import Wallet

263

from xrpl.models.transactions import Payment

264

from xrpl import transaction

265

266

# Setup

267

client = JsonRpcClient("https://s.altnet.rippletest.net:51234")

268

wallet = Wallet.from_seed("sEdT...")

269

270

# Create payment

271

payment_tx = Payment(

272

account=wallet.address,

273

destination="rReceiver...",

274

amount="1000000" # 1 XRP

275

)

276

277

# Method 1: Step-by-step

278

autofilled_tx = transaction.autofill(payment_tx, client)

279

signed_tx = transaction.sign(autofilled_tx, wallet)

280

result = transaction.submit(signed_tx, client)

281

282

# Method 2: All-in-one (recommended)

283

result = transaction.submit_and_wait(payment_tx, client, wallet)

284

print(f"Transaction result: {result.result}")

285

print(f"Transaction hash: {result.result['hash']}")

286

```

287

288

### Advanced Transaction Management

289

290

```python

291

from xrpl.clients import JsonRpcClient

292

from xrpl.wallet import Wallet

293

from xrpl.models.transactions import Payment, OfferCreate

294

from xrpl import transaction

295

import asyncio

296

297

def prepare_and_submit_transaction(tx, client, wallet):

298

"""Prepare and submit a transaction with error handling."""

299

300

try:

301

# Simulate first to check for issues

302

print("Simulating transaction...")

303

sim_result = transaction.simulate(tx, client)

304

print(f"Simulation result: {sim_result}")

305

306

# Submit if simulation successful

307

print("Submitting transaction...")

308

result = transaction.submit_and_wait(tx, client, wallet, check_fee=True)

309

310

if result.is_successful():

311

print(f"✅ Transaction successful: {result.result['hash']}")

312

return result

313

else:

314

print(f"❌ Transaction failed: {result.result}")

315

return None

316

317

except Exception as e:

318

print(f"❌ Error: {e}")

319

return None

320

321

# Usage

322

client = JsonRpcClient("https://s.altnet.rippletest.net:51234")

323

wallet = Wallet.from_seed("sEdT...")

324

325

payment = Payment(

326

account=wallet.address,

327

destination="rReceiver...",

328

amount="1000000"

329

)

330

331

result = prepare_and_submit_transaction(payment, client, wallet)

332

```

333

334

### Multisign Transaction Workflow

335

336

```python

337

from xrpl.clients import JsonRpcClient

338

from xrpl.wallet import Wallet

339

from xrpl.models.transactions import Payment

340

from xrpl import transaction

341

342

# Setup multisign scenario

343

client = JsonRpcClient("https://s.altnet.rippletest.net:51234")

344

wallet1 = Wallet.from_seed("sEdT1...")

345

wallet2 = Wallet.from_seed("sEdT2...")

346

347

# Create transaction requiring multiple signatures

348

payment = Payment(

349

account="rMultisigAccount...", # Account with signer list

350

destination="rReceiver...",

351

amount="5000000" # 5 XRP

352

)

353

354

# Autofill the transaction

355

autofilled_tx = transaction.autofill(payment, client)

356

357

# First signer

358

signed_tx1 = transaction.multisign(autofilled_tx, wallet1)

359

360

# Second signer adds their signature

361

signed_tx2 = transaction.multisign(signed_tx1, wallet2)

362

363

# Submit the multisigned transaction

364

from xrpl.models.requests import SubmitMultisigned

365

submit_request = SubmitMultisigned(tx_json=signed_tx2)

366

result = client.request(submit_request)

367

print(f"Multisign result: {result}")

368

```

369

370

### Batch Transaction Processing

371

372

```python

373

from xrpl.clients import JsonRpcClient

374

from xrpl.wallet import Wallet

375

from xrpl.models.transactions import Payment, Batch

376

from xrpl import transaction

377

378

def process_payment_batch(payments: list, client, wallet):

379

"""Process multiple payments efficiently."""

380

381

# Method 1: Individual transactions

382

results = []

383

for payment in payments:

384

try:

385

result = transaction.submit_and_wait(payment, client, wallet)

386

results.append(result)

387

print(f"Payment to {payment.destination}: {result.is_successful()}")

388

except Exception as e:

389

print(f"Failed payment to {payment.destination}: {e}")

390

results.append(None)

391

392

return results

393

394

# Method 2: Using batch transactions (if supported)

395

def create_batch_transaction(payments: list, account: str):

396

"""Create a batch transaction containing multiple payments."""

397

398

batch = Batch(

399

account=account,

400

batch=payments

401

)

402

return batch

403

404

# Usage

405

client = JsonRpcClient("https://s.altnet.rippletest.net:51234")

406

wallet = Wallet.from_seed("sEdT...")

407

408

payments = [

409

Payment(account=wallet.address, destination="rAddr1...", amount="1000000"),

410

Payment(account=wallet.address, destination="rAddr2...", amount="2000000"),

411

Payment(account=wallet.address, destination="rAddr3...", amount="3000000"),

412

]

413

414

# Process individually

415

results = process_payment_batch(payments, client, wallet)

416

417

# Or as batch (if network supports it)

418

batch_tx = create_batch_transaction(payments, wallet.address)

419

batch_result = transaction.submit_and_wait(batch_tx, client, wallet)

420

```

421

422

### Asynchronous Transaction Operations

423

424

```python

425

import asyncio

426

from xrpl.asyncio.clients import AsyncJsonRpcClient

427

from xrpl.asyncio import transaction

428

from xrpl.wallet import Wallet

429

from xrpl.models.transactions import Payment

430

431

async def submit_transactions_async(transactions: list, client, wallet):

432

"""Submit multiple transactions concurrently."""

433

434

# Create submission tasks

435

tasks = []

436

for tx in transactions:

437

task = transaction.submit_and_wait(tx, client, wallet)

438

tasks.append(task)

439

440

# Wait for all to complete

441

results = await asyncio.gather(*tasks, return_exceptions=True)

442

443

# Process results

444

successful = 0

445

for i, result in enumerate(results):

446

if isinstance(result, Exception):

447

print(f"Transaction {i} failed: {result}")

448

elif result.is_successful():

449

print(f"Transaction {i} successful: {result.result['hash']}")

450

successful += 1

451

else:

452

print(f"Transaction {i} failed: {result.result}")

453

454

print(f"Successfully submitted {successful}/{len(transactions)} transactions")

455

return results

456

457

async def main():

458

client = AsyncJsonRpcClient("https://s.altnet.rippletest.net:51234")

459

wallet = Wallet.from_seed("sEdT...")

460

461

# Create multiple payments

462

payments = [

463

Payment(account=wallet.address, destination=f"rAddr{i}...", amount=str(i * 1000000))

464

for i in range(1, 6)

465

]

466

467

try:

468

results = await submit_transactions_async(payments, client, wallet)

469

finally:

470

await client.close()

471

472

# Run async example

473

asyncio.run(main())

474

```

475

476

## Exceptions

477

478

```python { .api }

479

class XRPLReliableSubmissionException(XRPLException):

480

"""Exception for reliable submission failures during transaction processing."""

481

```