You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cartesi-rollups_versioned_docs/version-2.0/development/asset-handling.md
+86Lines changed: 86 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,10 +52,96 @@ The application’s off-chain layer often requires knowledge of its address to f
52
52
53
53
By calling [`relayDAppAddress()`](../api-reference/json-rpc/relays/relays.md), function of the `DAppAddressRelay` contract, it adds the dApp’s address as a new input for the Cartesi dApp to process. Next, the off-chain machine uses this address to generate a voucher for execution at the [`executeVoucher()`](../api-reference/json-rpc/application.md/#executevoucher) function of the `CartesiDApp` contract.
54
54
55
+
Below is a sample JavaScript code with the implementations to transfer tokens to whoever calls the application, notice that the `const call` variable is an encoded function data containing the token contract ABI, function name and also arguments like recipient and amount, while the actual `voucher` structure itself contains a destination (erc20 token contract where the transfer execution should occur), the payload (encoded function data in `call`) and finally a value field which is initialized to `0` meaning no Ether is intended to be sent alongside this transfer request.
To execute Ether withdrawal it is important to emit a voucher with the necessary details as regarding whom you intend to send the Ether to and also the amount to send, nevertheless since the Application contract Executes vouchers by making a [safeCall](https://github.com/cartesi/rollups-contracts/blob/cb52d00ededd2da9f8bf7757710301dccb7d536d/src/library/LibAddress.sol#L18C14-L18C22) to the destination, passing a value (Ether amount to send along with the call) and a payload (function signature to call), it's acceptable to leave the payload section empty if you do not intend to call any functions in the destination address while sending just the specified value of Ether to the destination address. If you intend to call a payable function and also send Ether along, you can add a function signature matching the payable function you intend to call to the payload field.
58
104
105
+
Below is another sample JavaScript code, this time the voucher structure has been modified to send ether to an address instead of calling a function in a smart contract, notice there is no `encodedFunctionData`, so the payload section is initialized to zeroHash.
By default, Cartesi nodes close one epoch every 7200 blocks. You can [manually set the epoch length](./cli-commands.md/#run) to facilitate quicker asset-handling methods.
Copy file name to clipboardExpand all lines: cartesi-rollups_versioned_docs/version-2.0/development/creating-an-application.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ Cartesi CLI has templates for the following languages – `cpp`, `cpp-low-level`
35
35
:::note Libraries for simplifying development
36
36
We have high-level framework and alternative templates that simplify development and enhances input management, providing a smoother and more efficient experience.
37
37
For Go use Rollmelette, for Rust use Crabrolls, for Python use python-Cartesi and for Typescript/Javascrips use Deroll.
38
+
Visit this [page](../resources/community-tools.md) to learn more about these and other available tools.
38
39
:::
39
40
40
41
## Implementing your application Logic
@@ -61,7 +62,7 @@ Below is a sample application that has been modified to include the logic to sim
Copy file name to clipboardExpand all lines: cartesi-rollups_versioned_docs/version-2.0/development/running-an-application.md
+65-53Lines changed: 65 additions & 53 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,86 +6,98 @@ resources:
6
6
title: CartesiScan
7
7
---
8
8
9
-
Running your application creates a docker container containing all required services, and exposes your application node on port `6751`, then an anvil network specific to your application on port `6751/anvil`. The node also logs all outputs received by your backend.
9
+
Running an application locally mimics the process of deploying an application to production on a testnet or mainnet environment. When working locally, your application’s smart contracts are deployed to an Anvil network, which acts as a local Ethereum environment. The main difference is that your application node runs on your own machine using Docker, rather than on a remote server. Running an application involves two main phases: first, you build your application, and then you deploy it to your local development network (devnet). This process allows you to test and debug your application in an environment that closely resembles the real blockchain, making it easier to catch issues early and ensure a smooth deployment to production later.
10
10
11
-
Here are the prerequisites to run the node:
11
+
## Building the application
12
12
13
-
- Docker Engine must be active.
14
-
- Cartesi machine snapshot successfully built with `cartesi build`.
13
+
“Building” in this context compiles your application into RISC-V architecture, this architecture enables computation done by your application to be reproducible and verifiable. While "Running" encompasses the process of publishing your application to your local node running on docker and also deploying the necessary contracts for your application to a local Anvil devnet.
15
14
16
-
To start the node, run:
15
+
With the Docker engine running, CD into your application and build by running:
17
16
18
17
```shell
19
-
cartesi run
18
+
cartesi build
20
19
```
21
20
22
-
Response:
21
+
The successful execution of this step will log this in your terminal:
23
22
24
23
```shell
25
-
[+] Pulling 4/0
26
-
✔ proxy Skipped - Image is already present locally 0.0s
27
-
✔ database Skipped - Image is already present locally 0.0s
28
-
✔ rollups-node Skipped - Image is already present locally 0.0s
29
-
✔ anvil Skipped - Image is already present locally 0.0s
30
-
✔ demo-application starting at http://127.0.0.1:6751
31
-
✔ anvil service ready at http://127.0.0.1:6751/anvil
32
-
✔ rpc service ready at http://127.0.0.1:6751/rpc
33
-
✔ inspect service ready at http://127.0.0.1:6751/inspect/demo-application
34
-
✔ demo-application machine hash is 0xa3ca2e40420f3c2424ca95549b6c16fd9b11c27d76b8ef9ae9bf78cde36829fc
35
-
✔ demo-application contract deployed at 0xa083af219355288722234c47d4c8469ca9af6605
36
-
(l) View logs (b) Build and redeploy (q) Quit
37
-
```
38
-
39
-
This command runs your backend compiled to RISC-V and packages it as a Cartesi machine. It is therefore important that after every code update, the application needs to be rebuilt then the run command executed again, the Cartesi CLI makes this process very easy and all you need do is hit the `<b>` button on your keyboard to trigger a rebuild and run command.
40
-
41
-
:::troubleshoot troubleshooting common errors
42
-
43
-
#### Error: Depth Too High
44
24
45
-
```shell
46
-
Attaching to 2bd74695-prompt-1, 2bd74695-validator-1
This indicates that the node is reading blocks too far behind the current blockchain state.
48
+
### Memory
52
49
53
-
#### Solution
50
+
To change the default memory size for the Cartesi Machine, you can personalize it by adding a specific label in your Dockerfile.
54
51
55
-
Create or modify a `.cartesi.env` file in your project directory and set:
52
+
The line below lets you define the memory size in megabytes (MB):
56
53
57
-
```shell
58
-
TX_DEFAULT_CONFIRMATIONS=1
54
+
```dockerfile
55
+
LABEL io.cartesi.rollups.ram_size=128Mi
59
56
```
60
57
61
-
This adjustment should align the node's block reading with the blockchain's current state.
62
-
58
+
:::note environment variables
59
+
You can create a `.cartesi.env` in the project's root and override any variable controlling the rollups-node.
63
60
:::
64
61
65
-
### Overview of Node Services
62
+
## Deploying the application to devnet
66
63
67
-
The `cartesi run`commandactivates several services essential for node operation: some of these services are not activated by default and can be activated by adding them to the `--service` flag when starting your application. The below command starts your application with all available services:
64
+
Running the deploymentcommandcompiles your application and publishes it to the node running in the devnet environment. It also deploys the required authority and application contracts to the local Anvil network.
68
65
69
-
```shell
70
-
cartesi run --services explorer,graphql,bundler,paymaster,passkey
71
-
```
66
+
You can deploy multiple applications to this environment. For each application, you can either create a new authority contract or link it to an existing one.
72
67
73
-
Each of these services runs independently and can be activated or deactivated at will by simply including or removing them from the list of services while running your application. Below is a breakdown of these services and their default URL's.
68
+
Prerequisites for Deployment
69
+
Before deploying your application, ensure the following:
74
70
75
-
- **Anvil Chain**: Runs a local blockchain available at `http://localhost:6751/anvil`.
71
+
- Docker Engine is active.
72
+
- The Devnet environment is running.
73
+
- A Cartesi machine snapshot has been successfully built using `cartesi build`.
76
74
77
-
- **GraphQL Playground**: An interactive IDE at `http://localhost:6751/graphql` for exploring the GraphQL server.
75
+
Once these prerequisites are met, proceed to deploy your application by running:
78
76
79
-
- **Explorer**: Monitors Rollups application activity and manages transactions via `http://localhost:6751/explorer`.
77
+
```shell
78
+
cartesi deploy
79
+
```
80
80
81
-
- **Inspect**: A diagnostic tool accessible at `http://localhost:6751/inspect/<app_name>` to inspect the node’s state.
81
+
This command compiles your backend to RISC-V, packages it as a Cartesi machine, then publishes it to the node running on the devnet.
82
82
83
-
- **Bundler**: A server accessible at `http://localhost:6751/bundler/rpc` to enable account abstraction by providing an alternative mempool for receiving and bundling user operations.
83
+
During deployment, you'll have to specify:
84
84
85
-
- **Paymaster**: An account abstraction implementation that works hand in hand with the bundler to sponsor gas fees for transactions handled by the bundler, available at `http://localhost:6751/paymaster`.
85
+
- Private key or Mnemonic to fund the deployment.
86
+
- The authority owner address.
87
+
- The application owner address.
88
+
- An application name (making it easier to identify your application instead of relying on the contract address).
86
89
87
-
- **Passkey**: Runs a local passkey server, that enables account generation and interaction with application without a traditional wallet, available at `http://localhost:6751/passkey`
90
+
Once the deployment is complete, you should have logs similar to the following:
88
91
89
-
:::note Testing tools
90
-
[NoNodo](https://github.com/Calindra/nonodo) is a Cartesi Rollups testing tool that works with host machine applications, eliminating the need for Docker or RISC-V compilation.
0 commit comments