Deploy using Validium CLI
Deploy a smart contract to Validium using the validium-cli in under 5 minutes
This tutorial shows you how to deploy and interact with a smart contract on Validium in less than 5 minutes. It will help you get familiar with the Validium smart contract development and deployment process using different tools.
In this section you will learn how to:
Build a smart contract named Counter.
Deploy the smart contract to the Validium Testnet.
Interact with the contract using scripts.
Prerequisites
Before you start, make sure that you’ve configured the Validium Testnet in your wallet.
Have at least 0.5 Validium Testnet VLDM. If you need more, use one of the faucets.
validium-cli
validium-cliSyntax:
npx validium-cli create <project-name>Create Validium Project
Use the command below to create a project
npx validium-cli create my-projectMove to the just created project:
Create a
.envfile and add these environment variables:
Add your account wallet private key here using which you want to deploy and interact with your contract. Also, you will need the Infura API key with the Holesky network enabled (the Underlying Ethereum network).
Review the Smart Contract
Review the contract inside contracts folder:
The Solidity smart contract contains four functions:
incrementincreases the value of the count state by 1 and emits theCountUpdatedevent.decrementdecreases the value of the count state by 1 and emits theCountUpdatedevent.addToCountadds a value_valueto the count state and emits theCountUpdatedevent.getCountreturns the current value of the count state.
Validium is EVM compatible. You can write smart contracts with Solidity or Vyper and use existing popular libraries like OpenZeppelin, just like on Ethereum.
Compile and Deploy the Smart Contract
Use this command to compile the smart contract:
It will compile and generate an artifacts folder named artifacts-zk .
Logs:
It shows:
Successfully compiled 2 Solidity files, becuase in thecontractsfolder we have two contracts,Counter.solandMessageBoard.sol,here we are taking the example ofCounter.solonly.
Deploy to Validium Testnet:
syntax:
If you want to create your own script to deploy the compiled smart contract then add your <script-file> path after the command.
It will ask to select the contract to deploy from the list of 'compiled contracts'.
Select Counter.sol as we are working with this contract now. I will again prompt to enter the constructor arguments (in the smart contract we have none), so simply return empty.
This will deploy the compiled contract to the Validium Testnet.
Logs:
Piece of cake right? 🎊
Check the Contract in Validium Block Explorer
Use the contract address from the deployment logs to see the deployed contract on the Validium Block Explorer or use the link from the logs directly.

You can also move to the Events tab and see the Greet event emitted through the constructor as a result of deployment:

Interact with the Deployed Contract
Go to
interact.tsfile insidedeployfolder:
syntax:
If you want to create your own script to interact with the deployed smart contract then add your <script-file> path after the command.
It will ask to select the contract to deploy from the list of 'compiled contracts'.
Select Counter.sol as we are working with this contract for now. I will prompt to enter the deployed contract address (copy from the deployments logs, it can also be found inside the deployments-zk folder). After providing the deployed contract address, it wil prompt to ask Select an action .
Select Call a view/pure function (read-only), it will list the available functions which can be executed under this selection, then select getCount to view the initial state of the count . After this call it will again prompt to ask Select an action .
This time select Call a function (state-changing) , it will list the available functions which can be executed. Select addToCount and provide any value (say 5).
After execution, again select Call a view/pure function (read-only) and call getCount .
Tada! 🎉 State updated!
Try this a couple of times more and then check the transactions in Validium Block Explorer:

Takeaways
validium-cli: This CLI tool streamlines deployment and facilitates seamless interaction with the Validium Network.EVM-compatibility: Validium is EVM-compatible and you can write smart contracts in Solidity or Vyper as in Ethereum.
Custom compilers: smart contracts deployed to Validium must be compiled with the customs compilers:
zksolcfor Solidity andzkvyperfor Vyper.
Next steps
Follow the same above steps to deploy your contract, changes can be made to
interact.tsfile and use your methods from the contract.Continue learning by Deploy using Quickstart Repository.
Last updated