sui_jsonrpc/api/
write.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use std::net::SocketAddr;
5
6use jsonrpsee::proc_macros::rpc;
7use sui_sdk_types::Address;
8
9use crate::msgs::{
10    DevInspectArgs,
11    DevInspectResults,
12    DryRunTransactionBlockResponse,
13    ExecuteTransactionRequestType,
14    SuiTransactionBlockResponse,
15    SuiTransactionBlockResponseOptions,
16};
17use crate::serde::BigInt;
18
19#[rpc(client, namespace = "sui")]
20pub trait WriteApi {
21    /// Execute the transaction. See [`ExecuteTransactionRequestType`] for details on how it's
22    /// handled by the RPC.
23    ///
24    /// `request_type` defaults to
25    /// [`WaitForEffectsCert`](ExecuteTransactionRequestType::WaitForEffectsCert).
26    #[method(name = "executeTransactionBlock")]
27    async fn execute_transaction_block(
28        &self,
29        tx_bytes: String,
30        signatures: Vec<String>,
31        options: Option<SuiTransactionBlockResponseOptions>,
32        request_type: Option<ExecuteTransactionRequestType>,
33    ) -> RpcResult<SuiTransactionBlockResponse>;
34
35    #[method(name = "monitoredExecuteTransactionBlock")]
36    async fn monitored_execute_transaction_block(
37        &self,
38        tx_bytes: String,
39        signatures: Vec<String>,
40        options: Option<SuiTransactionBlockResponseOptions>,
41        request_type: Option<ExecuteTransactionRequestType>,
42        client_addr: Option<SocketAddr>,
43    ) -> RpcResult<SuiTransactionBlockResponse>;
44
45    /// Runs the transaction in dev-inspect mode. Which allows for nearly any
46    /// transaction (or Move call) with any arguments. Detailed results are
47    /// provided, including both the transaction effects and any return values.
48    #[method(name = "devInspectTransactionBlock")]
49    async fn dev_inspect_transaction_block(
50        &self,
51        sender_address: Address,
52        tx_bytes: String,
53        gas_price: Option<BigInt<u64>>,
54        epoch: Option<BigInt<u64>>,
55        additional_args: Option<DevInspectArgs>,
56    ) -> RpcResult<DevInspectResults>;
57
58    /// Return transaction execution effects including the gas cost summary,
59    /// while the effects are not committed to the chain.
60    #[method(name = "dryRunTransactionBlock")]
61    async fn dry_run_transaction_block(
62        &self,
63        tx_bytes: String,
64    ) -> RpcResult<DryRunTransactionBlockResponse>;
65}