unsafe_paySui

Transaction Builder API

Send SUI coins to a list of addresses, following a list of amounts. This is for SUI coin only and does not require a separate gas coin object. Specifically, what pay_sui does are: 1. debit each input_coin to create new coin following the order of amounts and assign it to the corresponding recipient. 2. accumulate all residual SUI from input coins left and deposit all SUI to the first input coin, then use the first input coin as the gas coin object. 3. the balance of the first input coin after tx is sum(input_coins) - sum(amounts) - actual_gas_cost 4. all other input coints other than the first one 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.

  • recipients : <[SuiAddress]> - the recipients' addresses, the length of this vector must be the same as amounts.

  • amounts : <[BigInt_for_uint64]> - the amounts to be transferred to recipients, following the same order

  • 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_paySui

Request

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

Result

{
    "jsonrpc": "2.0",
    "result": {
        "txBytes": "AAACAAgCAAAAAAAAAAAgH0Rsxsqm3/Eh0VQFaOkeibfg029uAJUixZJlxiftA2ECAgABAQAAAQEDAAAAAAEBAO6zD03GdafUm4q+31jrLjc4+s/FVMgPSyerYqoCh49WAQt5u8+ixAlw7quMRTzjJYfJ1hNR/zb27pC0MBYHhxxzPc3WAAAAAAAgXEX36S/u7QkKKtpU8XNcRBlEsKmXblukgQ9d5q6P0hnusw9NxnWn1JuKvt9Y6y43OPrPxVTID0snq2KqAoePVugDAAAAAAAA0AcAAAAAAAAA",
        "gas": [
            {
                "objectId": "0x0b79bbcfa2c40970eeab8c453ce32587c9d61351ff36f6ee90b4301607871c73",
                "version": 14077245,
                "digest": "7DCPYGBYsBFoe25UNtdN4fKSNp5WpwHSixzfmtRU38iL"
            }
        ],
        "inputObjects": [
            {
                "ImmOrOwnedMoveObject": {
                    "objectId": "0x0b79bbcfa2c40970eeab8c453ce32587c9d61351ff36f6ee90b4301607871c73",
                    "version": 14077245,
                    "digest": "7DCPYGBYsBFoe25UNtdN4fKSNp5WpwHSixzfmtRU38iL"
                }
            }
        ]
    },
    "id": 1
}

Last updated