Skip to content

Mugen-Builders/fortune

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fortune dApp

This Fortune dApp is built using Sunodo, a Cartesi "Rollups as a Service" platform. Sunodo provides a robust set of tools to streamline the development workflow of Cartesi applications.

Built with Python, the dApp displays random quotes from a set of predefined lists using the Linux fortune package.

The fortune package is a program that shows a random quote or saying each time it's run. These quotes, known as "fortunes", range from funny to thought-provoking, and are taken from a varied collection of sources.

Requirements and Installation

The Sunodo CLI heavily uses Docker under the hood, so you must have it installed and up-to-date.

The recommended way to have all plugins ready for building is to install Docker Desktop.

macOS

If you have Homebrew installed, you can install Sunodo by running this command:

brew install sunodo/tap/sunodo

Alternatively, you can install Sunodo with Node.js by running:

npm install -g @sunodo/cli

Linux

You can either use Homebrew on Linux, or install Sunodo with:

npm install -g @sunodo/cli

Windows

Install WSL2 and the Ubuntu dsitro from Microsoft Store and install Sunodo with:

npm install -g @sunodo/cli

Building the application

To build the application, run:

sunodo build

You should see a Cartesi Machine snapshot output similar to this:

         .
        / \
      /    \
\---/---\  /----\
 \       X       \
  \----/  \---/---\
       \    / CARTESI
        \ /   MACHINE
         '

[INFO  rollup_http_server] starting http dispatcher service...
[INFO  rollup_http_server::http_service] starting http dispatcher http service!
[INFO  actix_server::builder] starting 1 workers
[INFO  actix_server::server] Actix runtime found; starting in Actix runtime
[INFO  rollup_http_server::dapp_process] starting dapp: python3 dapp.py
INFO:__main__:HTTP rollup_server url is http://127.0.0.1:5004
INFO:__main__:Sending finish

Manual yield rx-accepted (0x100000000 data)
Cycles: 2801607569
2801607569: 949fc4c3fc34333a0add4c1f367d2cc1d8c802c3ab3e5b96a78a116b78070dba
Storing machine: please wait

Running the application

This executes a Cartesi node for the application previously built with sunodo build.

sunodo run

It should print this output:

 ✔ Network 949fc4c3_default                       Created                                                                                                                                              0.0s
 ✔ Volume "949fc4c3_blockchain-data"              Created                                                                                                                                              0.0s
 ✔ Volume "949fc4c3_traefik-conf"                 Created
949fc4c3-prompt-1     | Anvil running at http://localhost:8545
949fc4c3-prompt-1     | GraphQL running at http://localhost:8080/graphql
949fc4c3-prompt-1     | Inspect running at http://localhost:8080/inspect/
949fc4c3-prompt-1     | Explorer running at http://localhost:8080/explorer/
949fc4c3-prompt-1     | Press Ctrl+C to stop the node

Interacting with the application

You can use the sunodo send command to send input payloads to your applications.

With your node running, open a new terminal tab. You can send a generic input to your application as follows:

 sunodo send generic

For local testing, select Foundry which gives you mock and test faucets to submit transactions:

> sunodo send generic
? Chain (Use arrow keys)
❯ Foundry
? Chain Foundry
? RPC URL http://127.0.0.1:8545
? Wallet Mnemonic
? Mnemonic test test test test test test test test test test test junk
? Account 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 9999.969170031383970357 ETH
? DApp address 0x70ac08179605AF2D9e75782b8DEcDD3c22aA4D0C
? Input String encoding
? Input (as string) Hello world, this is my first dApp
✔ Input sent: 0xd30150ee888a2bbf6b491812ee9ca28cb5754381eba3415ce4087322768c191f

You should see this notice in your node:

949fc4c3-validator-1  | INFO:__main__:Received input: Hello world, this is my first dApp
949fc4c3-validator-1  | INFO:__main__:Adding notice with payload: 'Received input: Hello world, this is my first dApp. This was the quote You'll feel much better once you've given up hope.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published