• Discover
  • Partner with us
  • Chapters
  • Blog

Build on MultiversX

Welcome to MultiversX!
Why Choose MultiversX?
Exploring MultiversX: Inside the SpaceVM
Exploring MultiversX: Lightning-Fast Consensus - SPoS -
Exploring MultiversX: Solution to Scaling

Tokens and standards (ESDT, MEX)
Simple Crowdfunding Smart Contract on MultiversX Part-1
Simple Crowdfunding Smart Contract on MultiversX Part-2
Simple Crowdfunding Smart Contract on MultiversX Part-3

Deploying a Smart Contract on MultiversX

Entering the MultiversX JavaScript Universe
MultiversX dApp Adventure: Build Your Ping-Pong dApp in 15 Minutes
Wallet Connection & Transaction Sending with MultiversX

Submit Your Final Project

Building the Contract

We’re ready to see if the pieces fit together. Let’s build the contract:

sc-meta all build

This will generate the .wasm and .abi.json files in the output folder — our contract’s DNA!

Setting Funding Targets

Let’s make it interesting! Here, we’re setting a funding goal that our campaign will aim to reach. Add this to src/crowdfunding.rs:

#!\[no_std\]

multiversx_sc::imports!();

#\[multiversx_sc::contract\]

pub trait Crowdfunding {

   #\[storage_mapper("target")\]

   fn target(&self) -> SingleValueMapper<BigUint>;

   #\[init\]

   fn init(&self, target: BigUint) {

       [self.target](http://self.target)().set(&target);

   }

}

init(): Sets the target funding goal and deadline.

Now, let’s test that initial setup! This will check if the contract correctly sets up the target. Inside the Crowdfunding folder, create a file named crowdfunding-init.scen.json:

Let’s define a scenario:

{

  "name": "crowdfunding deployment test",

  "steps": \[

    {

      "step": "setState",

      "accounts": {

        "address:my_address": {

          "nonce": "0",

          "balance": "1,000,000"

        }

      },

      "newAddresses": \[

        {

          "creatorAddress": "address:my_address",

          "creatorNonce": "0",

          "newAddress": "sc:crowdfunding"

        }

      \]

    },

    {

      "step": "scDeploy",

      "txId": "deploy",

      "tx": {

        "from": "address:my_address",

        "contractCode": "file:../output/crowdfunding.wasm",

        "arguments": \["500,000,000,000"\],

        "gasLimit": "5,000,000",

        "gasPrice": "0"

      },

      "expect": {

        "out": \[\],

        "status": "0",

        "gas": "\*",

        "refund": "\*"

      }

    },

    {

      "step": "checkState",

      "accounts": {

        "address:my_address": {

          "nonce": "1",

          "balance": "1,000,000",

          "storage": {}

        },

        "sc:crowdfunding": {

          "nonce": "0",

          "balance": "0",

          "storage": {

            "str:target": "500,000,000,000"

          },

          "code": "file:../output/crowdfunding.wasm"

        }

      }

    }

  \]

}

Save the file. Do you want to try it out first? Go ahead and issue this command on your terminal:

cargo test

Implementing Core Logic

The first thing we need to do is to configure the desired target amount and the deadline. The deadline will be expressed as the block timestamp after which the contract can no longer be funded. We will be adding 2 more storage fields and arguments to the constructor:

#\[view(getTarget)\]

  #\[storage_mapper("target")\]

  fn target(&self) -> SingleValueMapper<BigUint>;

  #\[view(getDeadline)\]

  #\[storage_mapper("deadline")\]

  fn deadline(&self) -> SingleValueMapper<u64>;

  #\[view(getDeposit)\]

  #\[storage_mapper("deposit")\]

  fn deposit(&self, donor: &ManagedAddress) -> SingleValueMapper<BigUint>;

  #\[init\]

  fn init(&self, target: BigUint, deadline: u64) {

      [self.target](http://self.target)().set(&target);

      self.deadline().set(&deadline);

  }


Previous
Next

Lesson discussion

Swap insights and ask questions about “Build on MultiversX”.

Enroll to participate
Start the course to unlock the discussion. Enrolling helps us keep conversations relevant to learners.
WebsiteDiscoverPartner with UsBlogEvents
Discover
CoursesCircleRustSoliditySolanaWeb3 FundamentalsBlockchain Basics
CompanyAbout UsBrand GuidelineFAQsTerms of UsePrivacy PolicyGDPR NoticeCookies
Don't miss any update!

Disclaimer: The information, programs, and events provided on https://risein.com is strictly for upskilling and networking purposes related to the technical infrastructure of blockchain platforms. We do not provide financial or investment advice, nor do we make any representations regarding the value, profitability, or future price of any blockchain or cryptocurrency. Users are encouraged to conduct their own research and consult with licensed financial professionals before engaging in any investment activities. https://risein.com disclaims any responsibility for financial decisions made by users based on the information provided here.

© 2026 Rise In, All rights reserved