Packages
packages.howToCall
How to call one Move function from a PTB: parameters explained, a TypeScript snippet and a JSON PTB.
Details
- Endpoint
- GET /v1/packages/:id/functions/:module/:function/call
- Credits
- 1
- Rate class
- Light. Counts against your light requests per second.
Explains each parameter of a Move function: a plain value or an object, a reference or by value, a well-known shared object such as the Clock at 0x6, and which type arguments to fill. TxContext is left out because the chain adds it. Returns a ready TypeScript snippet using Transaction.moveCall from @mysten/sui, a JSON PTB skeleton in the SDK v2 shape with placeholders, and whether a PTB can call the function at all (public or entry) with the reason if not.
Parameters
| Name | Type | Description |
|---|---|---|
| idrequired | string | Package id (0x...), the version whose function you want to call. |
| modulerequired | string | Module name, for example coin. |
| functionrequired | string | Function name, for example split. |
Request
Send your key in the x-api-key header, or leave it out to use the keyless tier.
curl "https://api.tide.ad/v1/packages/0x2/functions/coin/split/call" \
-H "x-api-key: YOUR_API_KEY"const res = await fetch("https://api.tide.ad/v1/packages/0x2/functions/coin/split/call", {
headers: {
"x-api-key": process.env.TIDE_API_KEY!,
},
});
const data = await res.json();Response
{
"packageId": "0x0000000000000000000000000000000000000000000000000000000000000002",
"module": "coin",
"function": "split",
"target": "0x2::coin::split",
"signature": "public fun split<T0>(&mut 0x2::coin::Coin<T0>, u64, &mut 0x2::tx_context::TxContext): 0x2::coin::Coin<T0>",
"visibility": "public",
"isEntry": false,
"callableFromPtb": true,
"notCallableBecause": null,
"typeParams": [
{
"name": "T0",
"constraints": [],
"declaration": "T0",
"explain": "Type argument for T0. Give the full type, for example 0x2::sui::SUI."
}
],
"params": [
{
"index": 0,
"type": "&mut 0x2::coin::Coin<T0>",
"access": "mutable reference",
"kind": "object",
"name": "coinId",
"tsArg": "tx.object(coinId)",
"explain": "An object of type 0x2::coin::Coin<T0>. Mutable borrow. The object is shared, or owned by the sender; its owner decides, check the object with objects.get."
},
{
"index": 1,
"type": "u64",
"access": "by value",
"kind": "pure",
"name": "u64Value",
"tsArg": "tx.pure.u64(u64Value)",
"explain": "A plain value of type u64. Pass it with tx.pure, it is not an object."
}
],
"txContext": "The function takes a TxContext. The chain adds it, do not pass it.",
"returns": [
{
"index": 0,
"type": "0x2::coin::Coin<T0>",
"abilities": [
"store",
"key"
],
"explain": "No drop ability: a later command must consume it (transfer it, pass it on or destroy it) or the transaction fails."
}
],
"typescript": "import { Transaction } from \"@mysten/sui/transactions\";\n\n// Fill these in: coinId, u64Value, typeArg0\n// T0: type argument\nconst tx = new Transaction();\nconst [result] = tx.moveCall({\n target: \"0x2::coin::split\",\n typeArguments: [typeArg0],\n arguments: [tx.object(coinId), tx.pure.u64(u64Value)],\n});\n// result: 0x2::coin::Coin<T0>",
"ptb": {
"version": 2,
"sender": "<sender address>",
"expiration": null,
"gasData": {
"budget": null,
"price": null,
"owner": null,
"payment": null
},
"inputs": [
{
"UnresolvedObject": {
"objectId": "<coinId>"
},
"$kind": "UnresolvedObject"
},
{
"Pure": {
"bytes": "AAAAAAAAAAA="
},
"$kind": "Pure"
}
],
"commands": [
{
"MoveCall": {
"package": "0x0000000000000000000000000000000000000000000000000000000000000002",
"module": "coin",
"function": "split",
"typeArguments": [
"<T0>"
],
"arguments": [
{
"Input": 0,
"type": "object",
"$kind": "Input"
}
]
},
"$kind": "MoveCall"
}
]
},
"packageVersion": 60,
"latestPackageId": "0x0000000000000000000000000000000000000000000000000000000000000002",
"note": null,
"asOf": {
"checkpoint": 341439584,
"timestamp": "2026-11-04T04:30:34.448Z",
"lagMs": 638
}
}Long lists are cut to a few items here.