Skip to content

Projet fin d'étude IOTA, CRUD Decentralized Identity on IOTA.

Notifications You must be signed in to change notification settings

IliasElabbassi/IOTA-SC-DID-manager

Repository files navigation

PFE

see others md file :

Prerequisites

  • Wasp (commit 3cd522ede8b496c0acc34221d56e2bfc76effe39 (HEAD -> develop, origin/develop, origin/HEAD))
  • Go 1.19.5
  • Linux/Wsl
  • Docker
  • Rust

resources

Preconfigured Development Docker

Starting

Run docker-compose up to start the setup.

Stopping

Press Ctrl-C to shut down the setup, but don't press it twice to force it. Otherwise, you can corrupt the Hornet database.

You can also shut down the setup with docker-compose down in a new terminal.

Reset

Run docker-compose down --volumes to shut down the nodes and to remove all databases.

Recreation

If you made changes to the Wasp code and want to use it inside the setup, you need to recreate the Wasp image.

Run docker-compose build

Seed

Run wasp-cli init to generate a seed, and you are ready to go.

seed generated : 0x8a79b784060d66b51515ad43d45eefd76034d17c2dce39f1a71a9155c48dcdcb do not use this in mainnet

Ports

The nodes will then be reachable under these ports:

Useful Information

  • To test smart contracts and run unit tests against smart contract functionality, the “solo” environment written in Go can be used.

  • Goshimer not used anymore for rust smart contract

  • A Wasp Node has it's own wallet. Where we need to send funds to, to deploy smart contracts.

  • Smart contracts for the IOTA network can be implemented in Rust and then compiled to a WebAssembly file.

  • Rust building env cargo new <project_name>
* Cargo.toml        # define dependencies of the smart contract
* src/lib.rs        # Source of the smart contract
* pkg/      
* target/

  • compile a rust lib to wasm :
    • Create a new Rust project using cargo
    • add the IOTA contract Library to the Cargo.tomlfile
    • Compile the contract using the cargo build --target wasm32-unknown-unknown command.
    • Deploy the compiled contract to the IOTA Tangle by sending a transaction containing the WASM bytecode.

  • To deploy a ISC with wasp-cli you need to be in the same file than the wasp-cli.json config file.

  • wasp-cli is a command line tool for interacting with Wasp and its smart contracts.

IOTA Smart Contract (ISC) env building

  • We need to have the wasp repo cloned localy.
  • After that add the bin folder inside the Wasp repo to the Path export PATH=$PATH:$(go env GOPATH)/bin assuming you already have Go
  • After that inside the wasp repo use make wasm to install schema tool
  • we then need to create a Schema space with schema -init nameOfyourEnv
  • then go inside this folder
  • You will see a schema.yaml file, this is the core of out Smart contract, by specifying each state, params and functions into this file it will generate all you core Smart contract.
  • to generate the code use schema -rs for rust code or schema -go for go.
  • then move inside the nameOfyourEnvimpl folder created, you will see the funcs.rs file, it's the only file you will need to change to create the logic of your contract.
  • to build go inside the nameOfyourEnvwasm folder created, and run wasm-pack build
  • You now have the wasm file located on the pkg folder

Memo

  • use Docker on WSL2 :

    • Download Docker Desktop for Windows.
    • From the Docker menu, select Settings and then General.
    • Select the Use WSL 2 based engine check box.
    • Select Apply & Restart.
  • Clean cargo build cargo clean

  • add a lib to Cargo.toml via cmd line ex : cargo add serde_with

  • unregister a wsl distrib : wsl --unregister <distrib_name>

    • to get the distrib name use : wsl -l -v
  • to get feedback after deployting use wasp-cli chain request <hash given after deployement>

Deploy

https://wiki.iota.org/shimmer/smart-contracts/guide/chains_and_nodes/setting-up-a-chain/#deploy-the-isc-chain

ISC

https://wiki.iota.org/shimmer/smart-contracts/guide/wasm_vm/schema/ https://wiki.iota.org/shimmer/smart-contracts/guide/wasm_vm/typedefs/ https://wiki.iota.org/shimmer/smart-contracts/guide/wasm_vm/state/ https://wiki.iota.org/shimmer/smart-contracts/guide/wasm_vm/params/

Errors encoutered

System has not been booted with systemd as init system (PID 1). Can't operate.

solution : https://stackoverflow.com/questions/52604068/using-wsl-ubuntu-app-system-has-not-been-booted-with-system-as-init-system-pi

sudo nano /etc/wsl.conf
[boot]
systemd=true
wsl.exe --shutdown

error[E0463]: can't find crate for core

solution : https://stackoverflow.com/questions/67898431/errore0463-cant-find-crate-for-core-while-building-rust-project-for-wasm32

rustup target add wasm32-unknown-unknown

error: failed to run custom build command for libsodium-sys v0.2.7

solution : libsodium-sys cant be generated into wasm.

error: sudo: add-apt-repository: command not found

solution :

sudo apt update
sudo apt install software-properties-common
sudo apt update

error : Cannot make install into wasp repo

solution : The problem was that some functionnalities used needed go aboce 1.16, but i had 1.13 installed into /usr/bin/go. But the want i wanted to use was located in /usr/local/go. I had to delete the /usr/bin one. And added the /usr/local one to the path.

error : cannot use "The version of quic-go you're using can't be built on Go 1.20 yet

solution : deletin go and installing version 1.19 (aka the one specified in the go.mod file)

error : cannot find command schema

solution : Go into the wasp repo and and the bin folder to path with export PATH=$PATH:$(go env GOPATH)/bin

error : Missing Lifetime Operator when generating wasm with wasm-pack build

solution : You just need to add <'a> to all the struct and ScFunc in the contract.rs file.

About

Projet fin d'étude IOTA, CRUD Decentralized Identity on IOTA.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published