How do I store and transfer tokens from a motoko backend canister in a react application?

I am building a react application with a motoko backend but I can’t figure out how to create an account that the backend canister is able to control and transfer ICP tokens from based on conditions in the app. For example if 5 players sit at a poker table all of their tokens would be placed into a pot (account controlled by canister) then when a user wins the game (conditions met) the app autonimously transfers the tokens from it’s own account to the user. I have been digging through documentation but I keep hitting dead ends. I have found examples of this in Rust but the link to the motoko example leads to 404. Can someone point me in the right direction?

The language of the backend does not matter to the frontend. You can simply swap out the Rust backend with Motoko and it will work just the same. Just make sure you export the same interface

Is it okay if I deploy the rust canister in this example (examples/rust/icp_transfer at master · dfinity/examples · GitHub) and make remote calls to it from my react app with the motoko backend?

Yes, that is fine. Just try things out :slightly_smiling_face:

1 Like

I got it. Thank you very much!