Skip to content

Sending Transaction

A Transaction in TRON is a system contract call, including TRX transfer, TRC10 transfer, contract call, create contract, vote witness, create new TRC10 token, and so on. The system contract call will be saved on the blockchain(in a block as a element in transactions list).

The routine for sending

A normal routine for sending a transaction is:

Create -> Sign -> Broadcast -> (wait) -> Lookup and get receipt

TronPy chooses the method chaining approach to create, sign, and broadcast any transaction. All type of transactions can be created via Tron.trx object.

from tronpy import Tron
from tronpy.keys import PrivateKey

client = Tron(network="nile")
priv_key = PrivateKey(bytes.fromhex("8888888888888888888888888888888888888888888888888888888888888888"))

txn = (
    client.trx.transfer("TJzXt1sZautjqXnpjQT4xSCBHNSYgBkDr3", "TVjsyZ7fYF3qLF6BQgPmTEZy1xrNNyVAAA", 1_000)
    .memo("test memo")
    .build()
    .sign(priv_key)
)
print(txn.txid)
print(txn.broadcast().wait())

In TronPy, the routine is:

  1. Create a TRON API client
  2. Create a TransactionBuilder via client.trx.foo functions
  3. Optionally set fee_limit, memo, or permission_id
  4. Call builder.build, create a Transaction object
  5. Call transaction.sign, to sign the transaction with a private key. Multiple calling of sign means multi-sign
  6. Call transaction.broadcast, to broadcast the transaction object
  7. Optionally call ret.wait, to wait and query the transaction receipt

The above steps are made easy through following APIs.

API reference

Trx

Trx(tron)

The Trx(transaction) API.

Methods:

Source code in tronpy/tron.py
301
302
def __init__(self, tron):
    self._tron = tron

account_permission_update

account_permission_update(owner: TAddress, perm: dict) -> TransactionBuilder

Update account permission.

Parameters:

Source code in tronpy/tron.py
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
def account_permission_update(self, owner: TAddress, perm: dict) -> "TransactionBuilder":
    """Update account permission.

    :param owner:
    :param perm: Permission dict from [`get_account_permission`][tronpy.Tron.get_account_permission]
    """

    if "owner" in perm:
        for key in perm["owner"]["keys"]:
            key["address"] = keys.to_hex_address(key["address"])
    if "actives" in perm:
        for act in perm["actives"]:
            for key in act["keys"]:
                key["address"] = keys.to_hex_address(key["address"])
    if perm.get("witness"):
        for key in perm["witness"]["keys"]:
            key["address"] = keys.to_hex_address(key["address"])

    return self._build_transaction(
        "AccountPermissionUpdateContract",
        dict(owner_address=keys.to_hex_address(owner), **perm),
    )

account_update

account_update(owner: TAddress, name: str) -> TransactionBuilder

Update account name. An account can only set name once.

Source code in tronpy/tron.py
417
418
419
420
421
422
def account_update(self, owner: TAddress, name: str) -> "TransactionBuilder":
    """Update account name. An account can only set name once."""
    return self._build_transaction(
        "UpdateAccountContract",
        {"owner_address": keys.to_hex_address(owner), "account_name": name.encode().hex()},
    )

asset_issue

asset_issue(
    owner: TAddress,
    abbr: str,
    total_supply: int,
    *,
    url: str,
    name: str = None,
    description: str = "",
    start_time: int = None,
    end_time: int = None,
    precision: int = 6,
    frozen_supply: list = None,
    trx_num: int = 1,
    num: int = 1,
) -> TransactionBuilder

Issue a TRC10 token.

Almost all parameters have resonable defaults.

Source code in tronpy/tron.py
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
def asset_issue(
    self,
    owner: TAddress,
    abbr: str,
    total_supply: int,
    *,
    url: str,
    name: str = None,
    description: str = "",
    start_time: int = None,
    end_time: int = None,
    precision: int = 6,
    frozen_supply: list = None,
    trx_num: int = 1,
    num: int = 1,
) -> TransactionBuilder:
    """Issue a TRC10 token.

    Almost all parameters have resonable defaults.
    """
    if name is None:
        name = abbr

    if start_time is None:
        # use default expiration
        start_time = current_timestamp() + 60_000

    if end_time is None:
        # use default expiration
        end_time = current_timestamp() + 60_000 + 1

    if frozen_supply is None:
        frozen_supply = []

    return self._build_transaction(
        "AssetIssueContract",
        {
            "owner_address": keys.to_hex_address(owner),
            "abbr": abbr.encode().hex(),
            "name": name.encode().hex(),
            "total_supply": total_supply,
            "precision": precision,
            "url": url.encode().hex(),
            "description": description.encode().hex(),
            "start_time": start_time,
            "end_time": end_time,
            "frozen_supply": frozen_supply,
            "trx_num": trx_num,
            "num": num,
            "public_free_asset_net_limit": 0,
            "free_asset_net_limit": 0,
        },
    )

asset_transfer

asset_transfer(
    from_: TAddress, to: TAddress, amount: int, token_id: int
) -> TransactionBuilder

Transfer TRC10 tokens.

Source code in tronpy/tron.py
326
327
328
329
330
331
332
333
334
335
336
def asset_transfer(self, from_: TAddress, to: TAddress, amount: int, token_id: int) -> TransactionBuilder:
    """Transfer TRC10 tokens."""
    return self._build_transaction(
        "TransferAssetContract",
        {
            "owner_address": keys.to_hex_address(from_),
            "to_address": keys.to_hex_address(to),
            "amount": amount,
            "asset_name": str(token_id).encode().hex(),
        },
    )

create_witness

create_witness(owner: TAddress, url: str) -> TransactionBuilder

Create a new witness, will consume 1_000 TRX.

Source code in tronpy/tron.py
532
533
534
535
def create_witness(self, owner: TAddress, url: str) -> "TransactionBuilder":
    """Create a new witness, will consume 1_000 TRX."""
    payload = {"owner_address": keys.to_hex_address(owner), "url": url.encode().hex()}
    return self._build_transaction("WitnessCreateContract", payload)

delegate_resource

delegate_resource(
    owner: TAddress,
    receiver: TAddress,
    balance: int,
    resource: str = "BANDWIDTH",
    lock: bool = False,
    lock_period: int = None,
) -> TransactionBuilder

Delegate bandwidth or energy resources to other accounts in Stake2.0.

Parameters:

  • owner

    (TAddress) –
  • receiver

    (TAddress) –
  • balance

    (int) –
  • resource

    (str, default: 'BANDWIDTH' ) –

    Resource type, can be "ENERGY" or "BANDWIDTH"

  • lock

    (bool, default: False ) –

    Optionally lock delegated resources for 3 days.

  • lock_period

    (int, default: None ) –

    Optionally lock delegated resources for a specific period. Default: 3 days.

Source code in tronpy/tron.py
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
def delegate_resource(
    self,
    owner: TAddress,
    receiver: TAddress,
    balance: int,
    resource: str = "BANDWIDTH",
    lock: bool = False,
    lock_period: int = None,
) -> "TransactionBuilder":
    """Delegate bandwidth or energy resources to other accounts in Stake2.0.

    :param owner:
    :param receiver:
    :param balance:
    :param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
    :param lock: Optionally lock delegated resources for 3 days.
    :param lock_period: Optionally lock delegated resources for a specific period. Default: 3 days.
    """

    payload = {
        "owner_address": keys.to_hex_address(owner),
        "receiver_address": keys.to_hex_address(receiver),
        "balance": balance,
        "resource": resource,
        "lock": lock,
    }
    if lock_period is not None:
        payload["lock_period"] = lock_period

    return self._build_transaction("DelegateResourceContract", payload)

deploy_contract

deploy_contract(owner: TAddress, contract: Contract) -> TransactionBuilder

Deploy a new contract on chain.

Source code in tronpy/tron.py
550
551
552
553
554
555
556
557
def deploy_contract(self, owner: TAddress, contract: Contract) -> "TransactionBuilder":
    """Deploy a new contract on chain."""
    contract._client = self.client
    contract.owner_address = owner
    contract.origin_address = owner
    contract.contract_address = None

    return contract.deploy()

freeze_balance

freeze_balance(
    owner: TAddress, amount: int, resource: str = "ENERGY"
) -> TransactionBuilder

Freeze balance to get energy or bandwidth, for 3 days.

Parameters:

  • owner

    (TAddress) –
  • amount

    (int) –
  • resource

    (str, default: 'ENERGY' ) –

    Resource type, can be "ENERGY" or "BANDWIDTH"

Source code in tronpy/tron.py
424
425
426
427
428
429
430
431
432
433
434
435
436
def freeze_balance(self, owner: TAddress, amount: int, resource: str = "ENERGY") -> "TransactionBuilder":
    """Freeze balance to get energy or bandwidth, for 3 days.

    :param owner:
    :param amount:
    :param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
    """
    payload = {
        "owner_address": keys.to_hex_address(owner),
        "frozen_balance": amount,
        "resource": resource,
    }
    return self._build_transaction("FreezeBalanceV2Contract", payload)

transfer

transfer(from_: TAddress, to: TAddress, amount: int) -> TransactionBuilder

Transfer TRX. amount in SUN.

Source code in tronpy/tron.py
317
318
319
320
321
322
def transfer(self, from_: TAddress, to: TAddress, amount: int) -> TransactionBuilder:
    """Transfer TRX. ``amount`` in `SUN`."""
    return self._build_transaction(
        "TransferContract",
        {"owner_address": keys.to_hex_address(from_), "to_address": keys.to_hex_address(to), "amount": amount},
    )

undelegate_resource

undelegate_resource(
    owner: TAddress, receiver: TAddress, balance: int, resource: str = "BANDWIDTH"
) -> TransactionBuilder

Cancel the delegation of bandwidth or energy resources to other accounts in Stake2.0

Parameters:

  • owner

    (TAddress) –
  • receiver

    (TAddress) –
  • balance

    (int) –
  • resource

    (str, default: 'BANDWIDTH' ) –

    Resource type, can be "ENERGY" or "BANDWIDTH"

Source code in tronpy/tron.py
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
def undelegate_resource(
    self, owner: TAddress, receiver: TAddress, balance: int, resource: str = "BANDWIDTH"
) -> "TransactionBuilder":
    """Cancel the delegation of bandwidth or energy resources to other accounts in Stake2.0

    :param owner:
    :param receiver:
    :param balance:
    :param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
    """

    payload = {
        "owner_address": keys.to_hex_address(owner),
        "receiver_address": keys.to_hex_address(receiver),
        "balance": balance,
        "resource": resource,
    }

    return self._build_transaction("UnDelegateResourceContract", payload)

unfreeze_balance

unfreeze_balance(
    owner: TAddress, resource: str = "ENERGY", *, unfreeze_balance: int
) -> TransactionBuilder

Unfreeze balance to get TRX back.

Parameters:

  • owner

    (TAddress) –
  • resource

    (str, default: 'ENERGY' ) –

    Resource type, can be "ENERGY" or "BANDWIDTH"

  • unfreeze_balance

    (int) –
Source code in tronpy/tron.py
448
449
450
451
452
453
454
455
456
457
458
459
460
def unfreeze_balance(self, owner: TAddress, resource: str = "ENERGY", *, unfreeze_balance: int) -> "TransactionBuilder":
    """Unfreeze balance to get TRX back.

    :param owner:
    :param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
    :param unfreeze_balance:
    """
    payload = {
        "owner_address": keys.to_hex_address(owner),
        "unfreeze_balance": unfreeze_balance,
        "resource": resource,
    }
    return self._build_transaction("UnfreezeBalanceV2Contract", payload)

unfreeze_balance_legacy

unfreeze_balance_legacy(
    owner: TAddress, resource: str = "ENERGY", receiver: TAddress = None
) -> TransactionBuilder

Unfreeze Stake 1.0 balance to get TRX back.

Parameters:

  • owner

    (TAddress) –
  • resource

    (str, default: 'ENERGY' ) –

    Resource type, can be "ENERGY" or "BANDWIDTH"

  • receiver

    (TAddress, default: None ) –
Source code in tronpy/tron.py
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
def unfreeze_balance_legacy(
    self, owner: TAddress, resource: str = "ENERGY", receiver: TAddress = None
) -> "TransactionBuilder":
    """Unfreeze Stake 1.0 balance to get TRX back.

    :param owner:
    :param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
    :param receiver:
    """
    payload = {
        "owner_address": keys.to_hex_address(owner),
        "resource": resource,
    }
    if receiver is not None:
        payload["receiver_address"] = keys.to_hex_address(receiver)
    return self._build_transaction("UnfreezeBalanceContract", payload)

vote_witness

vote_witness(owner: TAddress, *votes: tuple[TAddress, int]) -> TransactionBuilder

Vote for witnesses. Empty votes to clean voted.

Source code in tronpy/tron.py
537
538
539
540
541
def vote_witness(self, owner: TAddress, *votes: tuple[TAddress, int]) -> "TransactionBuilder":
    """Vote for witnesses. Empty ``votes`` to clean voted."""
    votes = [{"vote_address": keys.to_hex_address(addr), "vote_count": count} for addr, count in votes]
    payload = {"owner_address": keys.to_hex_address(owner), "votes": votes}
    return self._build_transaction("VoteWitnessContract", payload)

withdraw_rewards

withdraw_rewards(owner: TAddress) -> TransactionBuilder

Withdraw voting rewards.

Source code in tronpy/tron.py
543
544
545
546
def withdraw_rewards(self, owner: TAddress) -> "TransactionBuilder":
    """Withdraw voting rewards."""
    payload = {"owner_address": keys.to_hex_address(owner)}
    return self._build_transaction("WithdrawBalanceContract", payload)

withdraw_stake_balance

withdraw_stake_balance(owner: TAddress) -> TransactionBuilder

Withdraw all stake v2 balance after waiting for 14 days since unfreeze_balance call.

Parameters:

  • owner

    (TAddress) –
Source code in tronpy/tron.py
438
439
440
441
442
443
444
445
446
def withdraw_stake_balance(self, owner: TAddress) -> "TransactionBuilder":
    """Withdraw all stake v2 balance after waiting for 14 days since unfreeze_balance call.

    :param owner:
    """
    payload = {
        "owner_address": keys.to_hex_address(owner),
    }
    return self._build_transaction("WithdrawExpireUnfreezeContract", payload)

TransactionBuilder

TransactionBuilder(inner: dict, client: Tron, method: ContractMethod = None)

TransactionBuilder, to build a Transaction object.

Methods:

  • build –

    Build the transaction.

  • fee_limit –

    Set fee_limit of the transaction, in SUN.

  • memo –

    Set memo of the transaction.

  • permission_id –

    Set permission_id of the transaction.

  • with_owner –

    Set owner of the transaction.

Source code in tronpy/tron.py
232
233
234
235
236
237
238
239
240
241
242
243
244
245
def __init__(self, inner: dict, client: "Tron", method: ContractMethod = None):
    self._client = client
    self._raw_data = {
        "contract": [inner],
        "timestamp": current_timestamp(),
        "expiration": current_timestamp() + 60_000,
        "ref_block_bytes": None,
        "ref_block_hash": None,
    }

    if inner.get("type") in ["TriggerSmartContract", "CreateSmartContract"]:
        self._raw_data["fee_limit"] = self._client.conf["fee_limit"]

    self._method = method

build

build(*, offline: bool = False, ref_block_id: str = None, **kwargs) -> Transaction

Build the transaction.

Source code in tronpy/tron.py
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
def build(self, *, offline: bool = False, ref_block_id: str = None, **kwargs) -> Transaction:
    """Build the transaction."""
    if offline:
        if not ref_block_id:
            raise ValueError("ref_block_id is required when building offline transactions")
        if proto is None:
            raise ImportError(PROTOBUF_NOT_INSTALLED_ERROR_MESSAGE)
    else:
        ref_block_id = self._client.get_latest_solid_block_id()
    self._raw_data["ref_block_bytes"] = ref_block_id[12:16]
    self._raw_data["ref_block_hash"] = ref_block_id[16:32]
    if offline:
        txid = proto.calculate_txid_from_raw_data(self._raw_data)
        return Transaction(
            self._raw_data,
            client=None,
            method=self._method,
            txid=txid,
            permission=None,
        )
    return Transaction(self._raw_data, client=self._client, method=self._method)

fee_limit

fee_limit(value: int) -> TransactionBuilder

Set fee_limit of the transaction, in SUN.

Source code in tronpy/tron.py
270
271
272
273
def fee_limit(self, value: int) -> "TransactionBuilder":
    """Set fee_limit of the transaction, in `SUN`."""
    self._raw_data["fee_limit"] = value
    return self

memo

memo(memo: str | bytes) -> TransactionBuilder

Set memo of the transaction.

Source code in tronpy/tron.py
260
261
262
263
264
def memo(self, memo: str | bytes) -> "TransactionBuilder":
    """Set memo of the transaction."""
    data = memo.encode() if isinstance(memo, (str,)) else memo
    self._raw_data["data"] = data.hex()
    return self

permission_id

permission_id(perm_id: int) -> TransactionBuilder

Set permission_id of the transaction.

Source code in tronpy/tron.py
255
256
257
258
def permission_id(self, perm_id: int) -> "TransactionBuilder":
    """Set permission_id of the transaction."""
    self._raw_data["contract"][0]["Permission_id"] = perm_id
    return self

with_owner

with_owner(addr: TAddress) -> TransactionBuilder

Set owner of the transaction.

Source code in tronpy/tron.py
247
248
249
250
251
252
253
def with_owner(self, addr: TAddress) -> "TransactionBuilder":
    """Set owner of the transaction."""
    if "owner_address" in self._raw_data["contract"][0]["parameter"]["value"]:
        self._raw_data["contract"][0]["parameter"]["value"]["owner_address"] = keys.to_hex_address(addr)
    else:
        raise TypeError("can not set owner")
    return self

Transaction

Transaction(
    raw_data: dict,
    client: Tron = None,
    method: ContractMethod = None,
    txid: str = "",
    permission: dict = EMPTY,
    signature: list = None,
)

The Transaction object, signed or unsigned.

Methods:

  • broadcast –

    Broadcast the transaction to TRON network.

  • set_signature –

    set transaction signature

  • sign –

    Sign the transaction with a private key.

  • update –

    update Transaction, change ref_block and txID, remove all signature

Attributes:

  • txid (str) –

    The transaction id in hex.

Source code in tronpy/tron.py
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
def __init__(
    self,
    raw_data: dict,
    client: "Tron" = None,
    method: ContractMethod = None,
    txid: str = "",
    permission: dict = EMPTY,
    signature: list = None,
):
    self._raw_data: dict = raw_data
    self._signature: list = signature or []
    self._client = client

    self._method = method

    self.txid: str = txid
    """The transaction id in hex."""

    self._permission: dict | None = permission

    if (not self.txid or self._permission is EMPTY) and self._client:
        sign_weight = self._client.get_sign_weight(self)
        if "transaction" not in sign_weight:
            self._client._handle_api_error(sign_weight)
            return  # unreachable
        self.txid = sign_weight["transaction"]["transaction"]["txID"]

        # when account not exist on-chain
        self._permission = sign_weight.get("permission", None)

txid instance-attribute

txid: str = txid

The transaction id in hex.

broadcast

broadcast() -> TransactionRet

Broadcast the transaction to TRON network.

Source code in tronpy/tron.py
188
189
190
def broadcast(self) -> TransactionRet:
    """Broadcast the transaction to TRON network."""
    return TransactionRet(self._client.broadcast(self), client=self._client, method=self._method)

set_signature

set_signature(signature: list) -> Transaction

set transaction signature

Source code in tronpy/tron.py
192
193
194
195
def set_signature(self, signature: list) -> "Transaction":
    """set transaction signature"""
    self._signature = signature
    return self

sign

sign(priv_key: PrivateKey) -> Transaction

Sign the transaction with a private key.

Source code in tronpy/tron.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
def sign(self, priv_key: PrivateKey) -> "Transaction":
    """Sign the transaction with a private key."""

    if not self.txid:
        raise ValueError("txID not calculated")
    if self.is_expired:
        raise ValueError("expired")

    if self._permission is not None:
        addr_of_key = priv_key.public_key.to_hex_address()
        for key in self._permission["keys"]:
            if key["address"] == addr_of_key:
                break
        else:
            raise BadKey(
                "provided private key is not in the permission list",
                f"provided {priv_key.public_key.to_base58check_address()}",
                f"required {self._permission}",
            )
    sig = priv_key.sign_msg_hash(bytes.fromhex(self.txid))
    self._signature.append(sig.hex())
    return self

update

update()

update Transaction, change ref_block and txID, remove all signature

Source code in tronpy/tron.py
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
def update(self):
    """update Transaction, change ref_block and txID, remove all signature"""
    self._raw_data["timestamp"] = current_timestamp()
    self._raw_data["expiration"] = self._raw_data["timestamp"] + 60_000
    ref_block_id = self._client.get_latest_solid_block_id()
    # last 2 byte of block number part
    self._raw_data["ref_block_bytes"] = ref_block_id[12:16]
    # last half part of block hash
    self._raw_data["ref_block_hash"] = ref_block_id[16:32]

    self.txid = ""
    self._permission = None
    self._signature = []
    sign_weight = self._client.get_sign_weight(self)
    if "transaction" not in sign_weight:
        self._client._handle_api_error(sign_weight)
        return  # unreachable
    self.txid = sign_weight["transaction"]["transaction"]["txID"]

    # when account not exist on-chain
    self._permission = sign_weight.get("permission", None)
    # remove all _signature
    self._signature = []

TransactionRet

TransactionRet(iterable, client: Tron, method: ContractMethod = None)

              flowchart TD
              tronpy.tron.TransactionRet[TransactionRet]

              

              click tronpy.tron.TransactionRet href "" "tronpy.tron.TransactionRet"
            

Methods:

  • result –

    Wait the contract calling result.

  • wait –

    Wait the transaction to be on chain.

Attributes:

  • txid –

    The transaction id in hex.

Source code in tronpy/tron.py
50
51
52
53
54
55
def __init__(self, iterable, client: "Tron", method: ContractMethod = None):
    super().__init__(iterable)

    self._client = client
    self._txid = self["txid"]
    self._method = method

txid property

txid

The transaction id in hex.

result

result(timeout=30, interval=1.6, solid=False) -> dict

Wait the contract calling result.

Returns:

  • dict –

    Result of contract method

Source code in tronpy/tron.py
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
def result(self, timeout=30, interval=1.6, solid=False) -> dict:
    """Wait the contract calling result.

    :returns: Result of contract method
    """
    if self._method is None:
        raise TypeError("Not a smart contract call")

    receipt = self.wait(timeout, interval, solid)

    if receipt.get("result", None) == "FAILED":
        msg = receipt.get("resMessage", receipt["result"])

        if receipt["receipt"]["result"] == "REVERT":
            with contextlib.suppress(Exception):
                result = receipt.get("contractResult", [])
                if result and len(result[0]) > (4 + 32) * 2:
                    error_msg = tron_abi.decode_single("string", bytes.fromhex(result[0])[4 + 32 :])
                    msg = f"{msg}: {error_msg}"
        raise TvmError(msg)

    return self._method.parse_output(receipt["contractResult"][0])

wait

wait(timeout=30, interval=1.6, solid=False) -> dict

Wait the transaction to be on chain.

Returns:

  • dict –

    TransactionInfo

Source code in tronpy/tron.py
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
def wait(self, timeout=30, interval=1.6, solid=False) -> dict:
    """Wait the transaction to be on chain.

    :returns: TransactionInfo
    """

    get_transaction_info = self._client.get_transaction_info
    if solid:
        get_transaction_info = self._client.get_solid_transaction_info

    end_time = time.time() + timeout
    while time.time() < end_time:
        try:
            return get_transaction_info(self._txid)
        except TransactionNotFound:
            time.sleep(interval)

    raise TransactionNotFound("timeout and can not find the transaction")