Sophon Dapps (JS-glue)

Code generator to simplify creating a built-in Sophon Dapp

How to create new builtin Dapp.

  1. Clone this repository.

    bash $ git clone https://github.com/super-string/sophon.git

  2. Create a new directory for your Dapp. (./myapp)

    bash $ mkdir -p ./sophon/dapps/myapp/src/web

  3. Copy your frontend files to ./dapps/myapp/src/web (bundled ones)

    bash $ cp -r ./myapp-src/* ./sophon/dapps/myapp/src/web

  4. Instead of creating web3 in your app. Load (as the first script tag in head):

    ```html

    ```

    The inject.js script will create global web3 instance with proper provider that should be used by your dapp.

  5. Create ./sophon/dapps/myapp/Cargo.toml with you apps details. See example here: sophon-status Cargo.toml.

    ```bash $ git clone https://github.com/super-string/sophon-ui.git $ cd ./sophon-ui/ $ cp ./home/Cargo.toml ../sophon/dapps/myapp/Cargo.toml $ cp ./home/build.rs ../sophon/dapps/myapp/build.rs $ cp ./home/src/lib.rs ../sophon/dapps/myapp/src/lib.rs $ cp ./home/src/lib.rs.in ../sophon/dapps/myapp/src/lib.rs.in

    And edit the details of your app

    $ vim ../sophon/dapps/myapp/Cargo.toml # Edit the details $ vim ./sophon/dapps/myapp/src/lib.rs.in # Edit the details ```

    How to include your Dapp into Sophon?

  6. Edit dapps/Cargo.toml and add dependency to your application (it can be optional)

    ```toml

    Use git repo and version

    sophon-dapps-myapp = { path="./myapp" } ```

  7. Edit dapps/src/apps.rs and add your application to all_pages (if it's optional you need to specify two functions - see sophon-dapps-wallet example)

  8. Compile sophon.

    bash $ cargo build --release # While inside `sophon`

  9. Commit the results.

    bash $ git add myapp && git commit -am "My first Sophon Dapp".