IOTA — iota, unsafe (3/3)
API reference for IOTA. All methods ->
unsafe_moveCall
Creates an unsigned transaction to call a Move function.
Creates an unsigned transaction to execute a Move call on the network, by calling the specified function in the module of a given package.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):signer< IotaAddress >(required): the IOTA address of the transaction signer.package_object_id< ObjectID >(required): the ID of the Move package to invoke, e.g. 0x2.module< string >(required): the name of the Move module containing the target function, e.g. pay.function< string >(required): the name of the Move function to call, e.g. split.type_arguments< [TypeTag] >(required): the type arguments to be passed into the Move function.arguments< [IotaJsonValue] >(required): the function arguments, formatted as IOTA-compatible JSON values.gas< ObjectID >(optional): the gas object to use for the transaction. If not specified, one will be automatically selected from the signer's assets.gas_budget< BigInt_for_uint64 >(required): the maximum gas the transaction is allowed to consume. It will fail if exceeded.execution_mode< IotaTransactionBlockBuilderMode >(optional): the execution mode, indicating whether the transaction should be executed normally or as a dev inspect. Defaults to Commit if not provided.
Returns
TransactionBlockBytes< TransactionBlockBytes >
gas< [ObjectRef] >(required): the gas objects to be used for the transaction.inputObjects< [InputObjectKind] >(required): the input objects involved in the transaction.txBytes< Base64 >(required): the BCS-encoded transaction data bytes (without the type tag), represented as a base64 string.
Request example
curl -X POST https://rpc.ankr.com/iota_mainnet/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "unsafe_moveCall",
"params": [
"0xSIGNER_ADDRESS", // placeholder: IOTA address of the transaction signer
"0xPACKAGE_ID", // placeholder: Move package ID (e.g., 0x2)
"module_name", // placeholder: Move module name (e.g., "pay")
"function_name", // placeholder: Move function name (e.g., "split")
["0xTYPE_TAG"], // placeholder: list of type arguments (can be empty)
["IOTA_JSON_ARGUMENTS"], // placeholder: list of arguments in IOTA JSON format
"0xOPTIONAL_GAS_OBJECT_ID", // placeholder: gas object (optional, or use one from signer's owned coins)
"1000000", // placeholder: gas budget (as string, BigInt)
"Commit" // placeholder: execution mode (e.g., "Commit" or "DevInspect")
],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"digest": "0xTRANSACTION_DIGEST", // placeholder: transaction hash
"effects": {
"status": {
"status": "success" // execution status
},
"executedEpoch": "123", // epoch in which transaction was executed
"gasUsed": {
"computationCost": "1000000",
"storageCost": "50000",
"storageRebate": "45000",
"nonRefundableStorageFee": "0"
},
"created": [
{
"owner": {
"AddressOwner": "0xSIGNER_ADDRESS"
},
"reference": {
"objectId": "0xCREATED_OBJECT_ID",
"version": 12345678,
"digest": "0xOBJECT_DIGEST"
}
}
],
"mutated": [
{
"owner": {
"AddressOwner": "0xSIGNER_ADDRESS"
},
"reference": {
"objectId": "0xMUTATED_OBJECT_ID",
"version": 12345678,
"digest": "0xMUTATED_OBJECT_DIGEST"
}
}
],
"deleted": [
{
"objectId": "0xDELETED_OBJECT_ID",
"version": 12345678,
"digest": "0xDELETED_OBJECT_DIGEST"
}
],
"gasObject": {
"owner": {
"AddressOwner": "0xSIGNER_ADDRESS"
},
"reference": {
"objectId": "0xGAS_OBJECT_ID",
"version": 12345678,
"digest": "0xGAS_OBJECT_DIGEST"
}
}
},
"events": [
{
"id": {
"txDigest": "0xTRANSACTION_DIGEST",
"eventSeq": "0"
},
"packageId": "0xPACKAGE_ID",
"transactionModule": "module_name",
"sender": "0xSIGNER_ADDRESS",
"type": "0xPACKAGE::module::EventName",
"parsedJson": {
"key": "value"
}
}
],
"timestampMs": "1690000000000",
"checkpoint": "1234567"
}
}