Building your dApp
All the instructions listed on this page are for building using the Cartesi Coprocessor CLI. For an approach that does not use the CLI, please refer to the manual section of this tutorial.
Step 1: Bootstrap a Project
Create a new Cartesi dApp project:
cartesi-coprocessor create --dapp-name <project_name> --template <go, python, javascript, rust>
cd my-cartesi-project
Implement your business logic by editing the pre-generated child contract in the src
folder to customize your logic.
Step 2: Publish the Program
Publish your program to the Coprocessor:
cartesi-coprocessor publish --network <devnet, mainnet or testnet>
This command not only builds the image of your Cartesi Machine, containing the application logic, but also uploads it to a pre-signed URL generated by the coprocessor solver then finally publishes the upload ID generated by that process to the solver, so it can invoke your application logic whenever a smart contract makes a call to it.
Optional flags:
The publish command contains a couple of optional flags which could be used to configure the way and environment in which your publish process works, these include:
-
--environment <dev, prod or test>
: By default this is set to prod environment but can be changed to whichever of the other two options the developer specifies. It helps the developer specify in which environment he chose to publish his application, bear in mind that some environments like the test environment might be less stable and contain experimental updated compared to the others. -
--check-status <true or false>
: This is set to false by default but when activated, it'll run an extra check at the end of the publish process to confirm that the application has been received by the coprocessor solver and ready to receive inputs. -
--solver-url <SolverUrl>
: While there are multiple environment options available to chose from, you can also specify a personal solver URL which your application will be published to.
To be able to use these commands on your local environment you need to start up your devnet first.
Run the Cartesi Coprocessor Devnet Environment:
cartesi-coprocessor start-devnet
To stop and clean up the environment later, use:
cartesi-coprocessor stop-devnet