转账和交易

Transfer

转账 TRX ,单位是SUN。

用法

transfer(fromAddress, toAddress, amount)

参数

参数描述类型
fromAddress转账转出地址String
toAddress转账转入地址String
amount转账金额,单位是 SUNint

返回值

TransactionExtention,包括执行结果。

异常

IllegalException,转账失败时抛出此异常。

示例

TransactionExtention transaction = wrapper.transfer("TLtrDb1udekjDumnrf3EVeke3Q6pHkZxjm", "TP8LKAf3R3FHDAcrQXuwBEWmaGrrUdRvzb", 1_000_000);
Transaction signedTxn = wrapper.signTransaction(transaction);
String ret = wrapper.broadcastTransaction(signedTxn);

执行结果:

e794b5799adbecd5a82a365d3faed5888e9e99eb7bda2f943e3cc46e77a5da7c

getTransactionSignWeight

获取交易签名权重。

用法

getTransactionSignWeight(txn)

参数

参数描述类型
txnTransaction 对象Transaction

返回值

TransactionSignWeight 对象。

示例

TransactionSignWeight transaction = wrapper.getTransactionSignWeight(wrapper.getTransactionById("786c7516df88941e33ea44f03e637bd8c1ddcfd058634574102c6e3cfb93de0d"));

执行结果:

permission {
    permission_name: "owner"
    threshold: 1
    keys {
      address: "A,\303\3379\362\325AU\361\\\016\213q)Xr5\346\322X"
      weight: 1
    }
  }
  approved_list: "A,\303\3379\362\325AU\361\\\016\213q)Xr5\346\322X"
  current_weight: 1
  result {
  }
  transaction {
    ...
  }

getTransactionApprovedList

获取交易批准列表。

用法

getTransactionApprovedList(txn)

参数

参数描述类型
txnTransaction 对象Transaction

返回值

TransactionApprovedList 对象。

示例

TransactionApprovedList transaction = wrapper.getTransactionApprovedList(wrapper.getTransactionById("786c7516df88941e33ea44f03e637bd8c1ddcfd058634574102c6e3cfb93de0d"));

执行结果:


approved_list: "A,\303\3379\362\325AU\361\\\016\213q)Xr5\346\322X"
  result {
  }
  transaction {
    ...
  }

estimateBandwidth

计算交易所需的带宽。

用法

estimateBandwidth(Transaction txn)

参数

参数描述类型
txn需要计算带宽的交易体。必须是签名后的交易Transaction

返回值

交易所需的带宽,类型为 long

示例

long bandwidth = wrapper.estimateBandwidth(signedTxn);

执行结果:

266