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

# GS2-Money Script Trigger Reference

Reference for event triggers that call extended scripts



## Trigger

### createWallet

wallet creation


#### Synchronous Execution Script

The script is executed synchronously before the wallet creation process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| wallet | [Wallet](../sdk/#wallet) | Wallet |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow wallet creation |
| initialAmount | int | ✓ |  | 0 ~ 2147483645 | Initial Wallet balance - will be credited as a free grant |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local wallet = args.wallet

-- Business logic:
local permit = true
local initialAmount = 0

-- Result
result = {
  permit=permit,
  initialAmount=initialAmount
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the wallet creation process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| wallet | [Wallet](../sdk/#wallet) | Wallet |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local wallet = args.wallet

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### deposit

Wallet balance addition

**Related methods:**
depositByUserId - Deposit balance to Wallet by User ID


#### Synchronous Execution Script

The script is executed synchronously before the wallet balance addition process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before deposit |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after deposit |
| price | float | Purchase Price |
| depositCount | int | Quantity of premium currency to be granted |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow wallet balance addition |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local price = args.price
local depositCount = args.depositCount

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the wallet balance addition process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before deposit |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after deposit |
| price | float | Purchase Price |
| depositCount | int | Quantity of premium currency to be granted |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local price = args.price
local depositCount = args.depositCount

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  
### withdraw

Wallet balance consumption

**Related methods:**
withdraw - Consume balance from wallet


#### Synchronous Execution Script

The script is executed synchronously before the wallet balance consumption process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before withdraw |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after withdraw |
| withdrawCount | int | Quantity of premium currency to be consumed |
| paidOnly | bool | Whether to target only paid currency |

##### Result

|  | Type | Required | Default | Value Limits | Description |
| --- | --- | --- | --- | --- | --- |
| permit | bool | ✓ |  |  | Whether to allow wallet balance consumption |

##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local withdrawCount = args.withdrawCount
local paidOnly = args.paidOnly

-- Business logic:
local permit = true

-- Result
result = {
  permit=permit
}
```


#### Asynchronous Execution Script

The script is executed asynchronously after the wallet balance consumption process.

##### Request

| | Type | Description |
| --- | --- | --- |
| namespace | [Namespace](../sdk/#namespace) | Namespace |
| oldWallet | [Wallet](../sdk/#wallet) | Wallet before withdraw |
| newWallet | [Wallet](../sdk/#wallet) | Wallet after withdraw |
| withdrawCount | int | Quantity of premium currency to be consumed |
| paidOnly | bool | Whether to target only paid currency |


##### Implementation Example


**Lua**
```lua

-- Request
local namespace = args.namespace
local oldWallet = args.oldWallet
local newWallet = args.newWallet
local withdrawCount = args.withdrawCount
local paidOnly = args.paidOnly

-- Asynchronous scripts typically do not affect the API response.
-- These scripts are typically used for logging, analytics, external notifications, and similar purposes.

result = {
}
```


---
  



