XChain Platform Action - DEPLOY
This action deploys a smart contract to the XChain VM. Two formats:
- v0 — standard deployment. Non-stakeable.
- v1 — stakeable-contract deployment. Adds
COOLDOWN_BLOCKS+SLASH_DESTINATIONmetadata so the contract can accept STAKE v3 actions targeting it.
PARAMS
| Name | Type | Description |
|---|---|---|
VERSION |
String | Format Version (0 = standard, 1 = stakeable) |
CODE_ENCODING |
String | Hex-encoded UTF-8 contract source code |
GAS_LIMIT |
Integer | Maximum gas units allowed for deployment |
CONSTRUCTOR_PARAMS |
String | Optional constructor parameters (pipe-delimited in v0; single field in v1) |
COOLDOWN_BLOCKS |
Integer | v1 only — unstaking cooldown for STAKE v3 against this contract (1…100000) |
SLASH_DESTINATION |
String | v1 only — address that receives slashed stake. Pass BURN to send to the chain’s configured burn address. Optional — defaults to BURN if COOLDOWN_BLOCKS is set without a destination. |
Formats
Version 0 — Standard (non-stakeable)
VERSION|CODE_ENCODING|GAS_LIMIT|CONSTRUCTOR_PARAMS
Version 1 — Stakeable contract
VERSION|CODE_ENCODING|GAS_LIMIT|CONSTRUCTOR_PARAMS|COOLDOWN_BLOCKS|SLASH_DESTINATION- Both staking fields are optional in the wire format. A v1 DEPLOY with empty
COOLDOWN_BLOCKSis treated the same as a v0 deploy (the contract is not stakeable).SLASH_DESTINATIONwithoutCOOLDOWN_BLOCKSis rejected asinvalid: SLASH_DESTINATION (requires COOLDOWN_BLOCKS).
Examples
DEPLOY|0|<hex_code>|200000|arg1|arg2
Deploy a non-stakeable contract with constructor arguments
DEPLOY|0|<hex_code>|100000|
Deploy a non-stakeable contract with no constructor parameters
DEPLOY|1|<hex_code>|200000||1000|BURN
Deploy a stakeable contract: 1000-block cooldown on STAKE v3 unstakes,
slashed tokens go to the chain's burn address
DEPLOY|1|<hex_code>|200000||100|bc1q...recipient
Deploy a stakeable contract: 100-block cooldown, slashed tokens routed
to a specific recipient address (not BURN)
Rules
- Available on all chains
CODE_ENCODINGmust be valid hex-encoded UTF-8 JavaScript source code and must not exceed 64KB (65536 bytes decoded)GAS_LIMITmust be a positive integer- The VM validates syntax before charging gas:
- V8 compilation check — rejects JavaScript syntax errors
- Acorn metering pass — rejects syntax beyond ES2020 (the supported syntax set)
- Reserved identifier check — rejects code containing
__gas(reserved for gas metering)
- If syntax validation fails, the deployment is rejected with
invalid: CODE_ENCODING (<reason>)and no gas is charged - A non-blocking float usage warning is generated if decimal number literals are detected (visible in the execution record)
- A gas fee is charged at deployment:
VM_DEPLOY_BASE + (code_bytes * VM_DEPLOY_PER_BYTE) SOURCEaddress must hold sufficient XCHAIN tokens to cover the gas fee- If
CONSTRUCTOR_PARAMSis provided, the VM executes the contract’sinitializemethod immediately after deployment:- Constructor gas is added to the deployment gas:
total_gas = deploy_gas + constructor_gas - If the constructor fails (reverts, out of gas, etc.), the entire deployment is rolled back — the contract is not stored
- The caller pays the combined gas even on constructor failure
- Constructor gas is added to the deployment gas:
- A derived address is created for the contract in the format
C:<CHAIN>:<ACTION_INDEX>(e.g.,C:BTC:500). This address participates in the standard balance system for token custody via DEPOSIT/WITHDRAW.
Stakeable contracts (v1 staking fields)
COOLDOWN_BLOCKSmust be an integer in[1, 100000]. Sets the unstaking cooldown for STAKE v3 actions against this contract (overrides the globalSTAKING.COOLDOWN_BLOCKSfor v3 unstakes on this contract).SLASH_DESTINATIONaccepts either an address (must be valid on the deploying chain) or the literal sentinelBURN. The sentinel resolves to the chain’s configured burn address.- If
COOLDOWN_BLOCKSis set butSLASH_DESTINATIONis empty, the indexer defaultsSLASH_DESTINATIONto the chain’s burn address. - A contract deployed with both staking fields can receive STAKE v3 actions targeting it; without them, STAKE v3 rejects with
invalid: TARGET_CONTRACT_INDEX (contract is not stakeable). - Stakeable-contract metadata is immutable after deployment — there is no mechanism to update
COOLDOWN_BLOCKSorSLASH_DESTINATIONlater.
Notes
- The deployed contract is assigned an action index derived from the transaction that contains this action
CODE_ENCODINGis hex-encoded UTF-8 — decode withBuffer.from(hex, 'hex').toString('utf8')- The
contractstable stores the decoded plain-text JavaScript, not the hex encoding - The
api_versionfield (default 1) determines which gateway API version the contract targets - Use
EXECUTEto call methods on a deployed contract - Use
DEPOSITandWITHDRAWto transfer token balances into and out of the contract’s derived address - Deployed contracts are immutable — there is no mechanism to update code after deployment
VM_DEPLOY_BASEandVM_DEPLOY_PER_BYTEconstants are defined in the gas schedule configuration
Copyright © 2025–2026 Dankest, LLC
Based on XChain Platform by Dankest, LLC – https://dankest.llc
Licensed under the GNU Affero General Public License v3.0 (AGPL-3.0-or-later) with a commercial license available for proprietary use.
You may use, modify, and distribute this material under the terms of the License. See LICENSE and NOTICE for full terms. See the licensing overview.