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:
Step 2: Compiling the Contract
To compile our contract into a deployable format, run:
sc meta all build
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:
cd interactor
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: here
Swap insights and ask questions about “Build on MultiversX”.
Ask a question or share your thoughts about this lesson.