How to Deploy
Note
Before deployment, compile your source with pha-tomb and make sure you have the generated .pvm and .abi artifacts.
Step 1: decide which flow you need
Standalone custom contract
Use this for lowercase custom contract names such as my_contract.
Tool:
pha-deploy contract deploy
New token-backed contract
Use this for uppercase token symbols such as MYTOKEN.
Tool:
pha-deploy --create-token
Attach VM code to an existing token
Use this when the token already exists on-chain and you now want to bind VM code to it.
Tool:
pha-deploy contract attach
Upgrade an existing contract
Use this after the contract already exists on-chain.
Tool:
pha-deploy contract upgrade
Step 2: compile the contract
Example:
pha-tomb output:./build debug nativecheck:error my_contract.tombThe command needs pha-tomb 2.2.1 or later. An older version needs protocol:1 or an update with dotnet tool update --global pha-tomb. Without one of them, every constructor fails at deploy. The compiler quick start explains the protocol: option.
This generates artifacts under ./build/Output/.
Typical outputs:
my_contract.pvmmy_contract.abi- optional
my_contract.debug - optional
my_contract.asm
Step 3: deploy with the correct tool
Standalone custom contract
pha-deploy contract deploy \
--rpc https://testnet.phantasma.info/rpc \
--nexus testnet \
--chain main \
--wif <wif> \
--contract-name my_contract \
--script ./build/Output/my_contract.pvm \
--abi ./build/Output/my_contract.abiUpgrade a standalone custom contract
pha-deploy contract upgrade \
--rpc https://testnet.phantasma.info/rpc \
--nexus testnet \
--chain main \
--wif <wif> \
--contract-name my_contract \
--script ./build/Output/my_contract.pvm \
--abi ./build/Output/my_contract.abiAttach VM code to an existing token
pha-deploy contract attach \
--rpc https://testnet.phantasma.info/rpc \
--nexus testnet \
--chain main \
--wif <wif> \
--symbol MYTOKEN \
--script ./build/Output/MYTOKEN.pvm \
--abi ./build/Output/MYTOKEN.abiCreate a new token-backed contract
For a new token-backed contract, do not use contract deploy.
Use:
pha-deploy --create-token
See:
Important validator rules
contract deployis for lowercase custom contracts.- Uppercase token symbols belong to token-backed flows.
contract attachexpects an already existing token.- Token-backed contracts must satisfy token validation rules, including the required trigger surface such as
onMint. - For NFT tokens, series creation is still a separate step after token creation or attach.