> For the complete documentation index, see [llms.txt](/llms.txt)

# GS2-Script Transaction Actions

Specification of verify/consume/acquire transaction actions






## Acquire Action



### Gs2Script:InvokeScript

Execute the script

Synchronously executes the specified Lua script with the provided JSON arguments. Returns the execution result including status code, return value, transaction information, random number state, execution time, and standard output. Supports transaction handling for atomic operations across GS2 services.

**Quantity specification supported: NO**

**Reversible action: NO**

|  | Type | Condition | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- | --- |
| scriptId | string |  | ✓|  |  ~ 1024 chars | Script GRN |
| userId | string |  | |  |  ~ 128 chars | User ID<br>Specify `#{userId}` to substitute the currently logged-in user's ID. |
| args | string |  | | "{}" |  ~ 5242880 chars | Arguments (JSON Format) |
| randomStatus | RandomStatus |  | |  |  | Random number status |
| timeOffsetToken | string |  | |  |  ~ 1024 chars | Time offset token |




**JSON**
```json
{
    "action": "Gs2Script:InvokeScript",
    "request": {
        "scriptId": "[string]Script GRN",
        "userId": "[string]User ID",
        "args": "[string]Arguments (JSON Format)",
        "randomStatus": {
            "seed": "[long]Random Seed",
            "used": [
                {
                    "category": "[long]Category",
                    "used": "[long]Used Count"
                }
            ]
        },
        "timeOffsetToken": "[string]Time offset token"
    }
}
```

**YAML**
```yaml

action: Gs2Script:InvokeScript
request:
  scriptId: "[string]Script GRN"
  userId: "[string]User ID"
  args: "[string]Arguments (JSON Format)"
  randomStatus: 
    seed: "[long]Random Seed"
    used: 
    - category: "[long]Category"
      used: "[long]Used Count"
  timeOffsetToken: "[string]Time offset token"
```

**GS2-Script**
```lua

transaction.service("script").acquire.invoke_script({
    scriptId="[string]Script GRN",
    userId="[string]User ID",
    args="[string]Arguments (JSON Format)",
    randomStatus={
        seed="[long]Random Seed",
        used={
                {
                    category="[long]Category",
                    used="[long]Used Count"
                }
            }
    },
    timeOffsetToken="[string]Time offset token",
})
```


---



