Build on MultiversX
In this guide, we’ll take that crowdfunding contract we prepped and actually deploy it to the blockchain. We’ll handle the setup, compile the code, and run tests to make sure it’s ready for action!
What You’ll Need
Rust with the sc-meta package — since we all went through coding crowdfunding contract lesson; we should now both have Rust and sc-meta installed in our coding environment. If not please go and check the lesson.
VS Code (optional) — with rust-analyzer and CodeLLDB for the best experience.
Step 1: Set Up Your Contract
First, open up your project folder where we created our crowdfunding contract:
cd ~/MultiversX/SmartContracts/crowdfunding
or wherever you initialized the project. Inside, check out the Cargo.toml file, which lists the dependencies and tells Rust where our main contract file is (src/crowdfunding.rs). Here’s what to note:
- [lib] declares the contract's main file.
- Output will generate crowdfunding.wasm, which we’ll deploy to MultiversX.
Step 2: Compiling the Contract
To compile our contract into a deployable format, run:
sc meta all build
- After compiling, you’ll see .wasm and .abi.json files in your output folder. These are the building blocks for deploying the contract on MultiversX.
Step 3: Generate the Interactor
Based on the smart contract we have just created, we can generate interactors with just one command using sc-meta in the root folder of the contract:
sc meta all snippets
This creates a new interactor folder with necessary files like proxy.rs and interactor_main.rs. Add the interactor to the smart contract’s Cargo.toml file:
\[workspace\]
members = \[
".",
"meta",
"interactor"
\]
Step 4: Deploy the Contract
In this part, we’ll use an interactor to deploy the contract and test some basic functions:
- Navigate to the interactor:
cd interactor
- Deploy the Contract: Run the following command to deploy:
cargo run deploy
If all goes well, you’ll get feedback in the terminal confirming that the contract is live on MultiversX!
Congrats, You Deployed a Crowdfunding Contract!
Your contract is now live on MultiversX, ready for users to interact with it and support new projects. Want to learn more? Check out the MultiversX docs for advanced topics!
Reference: https://docs.multiversx.com/developers/tutorials/interactors-guide
Comments
You need to enroll in the course to be able to comment!