Deploying smart functions
Deploying a smart function to Jstz is different from deploying most web or JavaScript/TypeScript applications because you cannot change the code of a smart function or delete it after you deploy it. When you deploy a smart function, Jstz records code of the smart function in its ledger of transactions and there is no way to change or delete entries from the ledger.
Deploying to the local sandbox
You can use the local sandbox to test smart functions in a simulated environment.
Ensure that Docker is installed.
Build the smart function as described in Building smart functions.
Start the Jstz sandbox in a Docker container by running
jstz sandbox --container start
. The sandbox persists as long as the container is running.Deploy the built smart function with the
jstz deploy
command, including the-n dev
argument to deploy it to the sandbox, as in this example:bashjstz deploy dist/index.js -n dev
If the deployment is successful, the response includes the address of the deployed smart function.
If you need to fund the smart function, you can bridge funds from bootstrap accounts with the
jstz bridge deposit
command, as in this example, which uses the variable<ADDRESS>
for the address of the deployed smart function:bashjstz bridge deposit --from bootstrap1 --to <ADDRESS> --amount 1000 -n dev
Verify that the smart function is deployed by calling it with the
jstz run
command or by checking its balance by running this command:bashjstz account balance -a <ADDRESS> -n dev