Prerequisites
Before you begin, ensure you have the following installed:- Rust and Cargo (for compiling smart contracts)
- Node.js and npm (for running JavaScript deployment scripts)
- Stellar CLI
Initialize a sample Rust Contract
hello-world/target/wasm32v1-none/release/hello_world.wasm
Create a Node Project
- Create a new directory for your Node.js project and navigate into it:
- Initialize a new Node.js project and install necessary dependencies:
Set Up Deployment Scripts
Imports
Import necessary modules in your JavaScript file (save it asdeploy.mjs to enable ES module imports):
Installing the Wasm on the network
Create a function to upload the compiled Wasm file:uploadContractWasm Stellar operation, which when wrapped in a transaction is sent to the network.
Deploy contract
Deploy the contract by referencing the Wasm hash:createCustomContract stellar operation, which when wrapped in a transaction is sent to the network, generating a contract address.