I'm assuming you have set up Rust's toolchain and installed cargo-component
. If not, please refer to Golem Cloud documentation for instructions.
With that done, let's start by building our Wasm binary with the following command:
cargo component build --release -p wasm
Then upload the Wasm binary and run it on Golem Cloud (skip to step 6 if you have already set up Golem CLI):
- Download the latest version of Golem CLI by signing up for the Developer Preview.
- Install Golem CLI by running
cargo install golem-cli
. - Run
golem-cli account get
to go through the authorization process if you haven't done so. cd
to our project directory.- Run the following command to upload the binary.
golem-cli template add --template-name wordle target/wasm32-wasi/release/wasm.wasm
- Then run this command to create a worker for our app.
golem-cli worker add --worker-name wordle-wrkr-1 --template-name wordle
- Define a shell alias to invoke the instance. For example:
alias wordle='golem-cli worker invoke-and-await --worker-name wordle-wrkr-1 --template-name wordle --function $*'
- Now let's play! 🎉
- Run the
new-game
command to start a new game. The game will tell us the number of letters for the word we'll be guessing.
wordle golem:wordle/api/new-game --parameters '[]'
- Run the
continue-game
command to make our first guess. And repeat the same command if we don't get lucky to win.
wordle golem:wordle/api/continue-game --parameters '["WORDLE_IS_FUN"]'
- If the game is too hard, take some breaks.😅 Upon resuming, if we don't remember where the game is at, we can always run the
game-status
command to remind ourselves of the number of letters for the word and how we did with our past guesses.
wordle golem:wordle/api/game-status --parameters '[]'
Check out my other Golem projects here (also a recommended project structure/template) and here. Have fun!