Skip to main content

unsafe_payAllSui

Transaction Builder API

Send all SUI coins to one recipient. This is for SUI coin only and does not require a separate gas coin object. Specifically, what pay_all_sui does are: 1. accumulate all SUI from input coins and deposit all SUI to the first input coin 2. transfer the updated first coin to the recipient and also use this first coin as gas coin object. 3. the balance of the first input coin after tx is sum(input_coins) - actual_gas_cost. 4. all other input coins other than the first are deleted.

Parameters

  • signer : <SuiAddress> - the transaction signer's Sui address
  • input_coins : <[ObjectID]> - the Sui coins to be used in this transaction, including the coin for gas payment.
  • recipient : <SuiAddress> - the recipient address,
  • gas_budget : <BigInt_for_uint64> - the gas budget, the transaction will fail if the gas cost exceed the budget

Returns

  • TransactionBytes : <TransactionBytes>
    • gas : <[ObjectRef]> - the gas object to be used
    • inputObjects : <[InputObjectKind]> - objects to be used in this transaction
    • txBytes : <[Base64]> - BCS serialized transaction data bytes without its type tag, as base-64 encoded string.

Example Request and Result for unsafe_payAllSui

Request

curl --location 'https://sui-testnet.blastapi.io/<project-id>' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"id": 1,
"method": "unsafe_payAllSui",
"params": [
"0x00c364252964511b32b084c17a492093d5b762cbe2766d46911912718e56950f",
[
"0x0b79bbcfa2c40970eeab8c453ce32587c9d61351ff36f6ee90b4301607871c73"
],
"0xeeb30f4dc675a7d49b8abedf58eb2e3738facfc554c80f4b27ab62aa02878f56",
"2000"
]
}'

Result

{
"jsonrpc": "2.0",
"result": {
"txBytes": "AAABACDusw9NxnWn1JuKvt9Y6y43OPrPxVTID0snq2KqAoePVgEBAQABAAAAw2QlKWRRGzKwhMF6SSCT1bdiy+J2bUaRGRJxjlaVDwELebvPosQJcO6rjEU84yWHydYTUf829u6QtDAWB4cccz3N1gAAAAAAIFxF9+kv7u0JCiraVPFzXEQZRLCpl25bpIEPXeauj9IZAMNkJSlkURsysITBekkgk9W3Ysvidm1GkRkScY5WlQ/oAwAAAAAAANAHAAAAAAAAAA==",
"gas": [
{
"objectId": "0x0b79bbcfa2c40970eeab8c453ce32587c9d61351ff36f6ee90b4301607871c73",
"version": 14077245,
"digest": "7DCPYGBYsBFoe25UNtdN4fKSNp5WpwHSixzfmtRU38iL"
}
],
"inputObjects": [
{
"ImmOrOwnedMoveObject": {
"objectId": "0x0b79bbcfa2c40970eeab8c453ce32587c9d61351ff36f6ee90b4301607871c73",
"version": 14077245,
"digest": "7DCPYGBYsBFoe25UNtdN4fKSNp5WpwHSixzfmtRU38iL"
}
}
]
},
"id": 1
}