How do I generate the content from the `wasm` folder?

290 views Asked by At

I'm trying to build from scratch a smart contract. I'm starting from cargo new my-contract. I wired the MultiversX dependencies and now cargo run does not complain.

Now when I run mxpy contract build I get

FileNotFoundError: [Errno 2] No such file or directory: '/home/bogdan/workspace/sc-from-scratch/wasm'

When I look at the other templates, I see that the content of this wasm folder is generated.

This is the relevant commit for my question: https://github.com/bogdan-marian/sc-from-scratch/commit/aa6f912e6bca413a91f18c9de52257390645b139

How do I generate the content from the wasm folder?

3

There are 3 answers

0
Bogdan Oloeriu On BEST ANSWER

It turns out that there is more to this question than I initially believed. I ended up creating an entire tutorial about how to create from scratch a smart contract. Short version is

  • you need to add the wasm folder by hand
  • once you add the meta crate later the content of this folder will be generated for you. This is where you can see me going through this entire flow: https://youtu.be/UYU9Gqw8ldg
0
Protocole On

Did you try to do a cargo build before building the smart contract itself?

It will install dependencies, and generate appropriate folders. If it still does not create the wasm folder, did you check your dependencies in your cargo.toml file ?

You should have something near this:

[package]
name = "router"
version = "0.0.0"
authors = [ "you",]
edition = "2018"
publish = false

[lib]
path = "src/lib.rs"

[features]
wasm-output-mode = [
  "elrond-wasm-node",
  "token_send/wasm-output-mode",
]

[dependencies.token_send]
path = "../../common/modules/token_send"

[dependencies.elrond-wasm]
version = "0.21"
features = ["derive"]

[dependencies.elrond-wasm-derive]
version = "0.21"

[dependencies.elrond-wasm-node]
version = "0.21"
optional = true

[dev-dependencies.elrond-wasm-debug]
version = "0.21"

[dependencies.pair]
path = "../pair"

source

0
Martin W On

I would suggest starting out with a wasm folder from one of the example projects, appropriate to the elrond-wasm version you are using.

In newer versions the content of the wasm/src/lib.rs will be generated by the meta subproject you should also have.

In general your life will be a lot easier if you use one of the defined templates using erdpy contract new as described here

For example

erdpy contract new --template adder