diff --git a/docs/2_architecture/components/2_payment_service_contract.md b/docs/2_architecture/components/2_payment_service_contract.md index 0c8a60244a..c54921dcda 100644 --- a/docs/2_architecture/components/2_payment_service_contract.md +++ b/docs/2_architecture/components/2_payment_service_contract.md @@ -3,9 +3,9 @@ The Payment Service handles users payments to fund the verification of their proofs. To be able to use the batcher, a user must fund its transactions. -For this, there is a simple Batcher Payment System. +For this, there is a simple Payment Service. -The Batcher has an associated Batcher Payments smart contract, +The Batcher has an associated `Batcher Payments` smart contract, which is in charge of receiving user's payments, and it guarantees that it can only spend these funds to send users' proofs to Aligned. diff --git a/docs/3_guides/0_submitting_proofs.md b/docs/3_guides/0_submitting_proofs.md index f87d93ae5b..4354632744 100644 --- a/docs/3_guides/0_submitting_proofs.md +++ b/docs/3_guides/0_submitting_proofs.md @@ -60,33 +60,32 @@ This will create the ECDSA keystore file in `~/.aligned_keystore/keystore0` - If you have the EigenLayer CLI installed, the keystore can be generated following [these](https://docs.eigenlayer.xyz/eigenlayer/operator-guides/operator-installation#import-keys) instructions. The key will be stored into `~/.eigenlayer/operator_keys`. -## 2. Fund the batcher +## 2. Send funds to Aligned -To be able to send proofs to Aligned using the Batcher, the user must fund its transactions. For this, there is a simple Batcher Payment System. +To send proofs to Aligned using the Batcher, the user must first deposit some funds in Aligned to pay for the verification of his proofs. To use it, you can use the `aligned` CLI, as shown with the following example: ```bash -aligned deposit-to-batcher \ +aligned deposit-to-batcher \ --rpc_url https://ethereum-holesky-rpc.publicnode.com \ --network holesky \ --keystore_path \ --amount 0.1ether ``` -These commands allow the usage of the following flags: +This command allows the usage of the following flags: -- `--payment_service_addr` to specify the address of the Batcher Payment Service smart contract. - `--rpc_url` to specify the rpc url to be used. -- `--network` to specify the chain id to be used. Could be holesky or devnet. +- `--network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. - `--keystore_path` the path to the keystore. - `--amount` the number of ethers to transfer to the Batcher. -- Note: `--amount` flag parameter must be with the shown format. The amount followed by the `ether` keyword to specify how many ethers you wish to deposit to the Batcher. +- Note: `--amount` flag parameter must be with the shown format, `XX.XXether`. After depositing funds, you can verify the Service has correctly received them by executing the following command: ```bash -aligned get-user-balance \ +aligned get-user-balance \ --rpc_url https://ethereum-holesky-rpc.publicnode.com \ --network holesky \ --user_addr @@ -95,7 +94,7 @@ aligned get-user-balance \ These commands allow the usage of the following flags: - `--rpc_url` to specify the rpc url to be used. -- `--network` to specify the chain id to be used. Could be holesky or devnet. +- `--network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. - `--user_addr` the address of the user that funded the Batcher. ## 3. Submit your proof to the batcher @@ -109,9 +108,8 @@ Proof submission is done via the `submit` command of the Aligned CLI. The argume * `vm_program`: When the proving system involves the execution of a program in a zkVM, this argument is associated with the compiled program or some other identifier of the program. * `pub_input`: The path to the file with the public input associated with the proof. * `batcher_url`: The batcher websocket URL. -* `chain` to specify the chain id to be used. Could be holesky or devnet. +* `network` to specify the netowrk to be used. Can be `devnet`, `holesky-stage` or `holesky`. * `rpc_url`: The RPC Ethereum node URL. -* `payment_service_addr`: The Ethereum address of the Batcher Payments System contract. * `proof_generator_addr`: An optional parameter that can be used in some applications to avoid front-running. * `batch_inclusion_data_directory_path`: An optional parameter indicating the directory where to store the batcher response data. If not provided, the folder with the responses will be created in the current directory. @@ -132,7 +130,7 @@ aligned submit \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **Example** @@ -146,7 +144,7 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ### Risc0 proof @@ -167,7 +165,7 @@ aligned submit \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **NOTE**: As said above, Aligned currently supports Risc0 proofs from `risc0-zkvm` version `v1.0.1`. For generating proofs using `cargo risc-zero` please ensure you are using `v1.0.1` or your proof will not be verified. @@ -193,7 +191,7 @@ aligned submit \ --aligned_verification_data_path ~/.aligned/aligned_verification_data \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ### GnarkPlonkBn254, GnarkPlonkBls12_381 and Groth16Bn254 @@ -212,7 +210,7 @@ aligned submit \ --batch_inclusion_data_directory_path [batch_inclusion_data_directory_path] \ --keystore_path \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` **Examples**: @@ -227,7 +225,7 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ```bash @@ -240,7 +238,7 @@ aligned submit \ --batcher_url wss://batcher.alignedlayer.com \ --keystore_path ~/.aligned_keystore/keystore0 \ --network holesky \ ---rpc_url https://ethereum-holesky-rpc.publicnode.com +--rpc_url https://ethereum-holesky-rpc.publicnode.com ``` ```bash diff --git a/docs/3_guides/1.2_SDK_api_reference.md b/docs/3_guides/1.2_SDK_api_reference.md index 9df3507a71..1b1a0a9c99 100644 --- a/docs/3_guides/1.2_SDK_api_reference.md +++ b/docs/3_guides/1.2_SDK_api_reference.md @@ -290,7 +290,7 @@ Should be used before submitting proofs to the batcher. Wallet chain id needs to wallet = wallet.with_chain_id(chain_id); ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the Ethereum RPC node. @@ -303,7 +303,7 @@ wallet = wallet.with_chain_id(chain_id); - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. -## `estimate_fee` +### `estimate_fee` Estimates the fee the user would have to pay for submitting a proof to Aligned. Depending on the priority the user wants to have in the batch, the `estimate` parameter can be set. @@ -315,7 +315,7 @@ pub async fn estimate_fee( ) -> Result ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the Ethereum RPC node. - `estimate` - The parameter to set the priority for the proof to be included in the batch. It can be one @@ -330,7 +330,7 @@ pub async fn estimate_fee( - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. -## `compute_max_fee` +### `compute_max_fee` Computes `max_fee` for a proof based on the number of proofs in a batch (`num_proofs_per_batch`) and number of proofs (`num_proofs`) in that batch the user would pay for i.e (`num_proofs` / `num_proofs_per_batch`). @@ -342,7 +342,7 @@ pub async fn compute_max_fee( ) -> Result ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the Ethereum RPC node. - `num_proofs` - The number of proofs in a batch the user would pay for. @@ -357,7 +357,7 @@ pub async fn compute_max_fee( - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. -## `fee_per_proof` +### `fee_per_proof` Returns the `fee_per_proof` based on the current gas price for a batch compromised of `num_proofs_per_batch` i.e. (1 / `num_proofs_per_batch`). @@ -368,7 +368,7 @@ pub async fn fee_per_proof( ) -> Result ``` -### Arguments +#### Arguments - `eth_rpc_url` - The URL of the users Ethereum RPC node. - `num_proofs_per_batch` - The number of proofs within a batch. @@ -381,3 +381,55 @@ pub async fn fee_per_proof( - `EthereumProviderError` if there is an error in the connection with the RPC provider. - `EthereumCallError` if there is an error in the Ethereum call. + + +### `deposit_to_aligned` + +Funds the batcher payment service in name of the signer + +pub async fn deposit_to_aligned( + amount: U256, + signer: SignerMiddleware, LocalWallet>, + network: Network, +) -> Result { + +#### Arguments +`amount` - The amount to be paid. +`signer` - The signer middleware of the payer. +`network` - The network on which the payment will be done. + +#### Returns +The receipt of the payment transaction. + +#### Errors +`SendError` if there is an error sending the transaction. +`SubmitError` if there is an error submitting the transaction. +`PaymentFailed` if the payment failed. + + +### `get_balance_in_aligned` + +Queries a User's balance that was deposited in Aligned + +```rust +pub async fn get_balance_in_aligned( + user: Address, + eth_rpc_url: &str, + network: Network, +) -> Result { +``` + +#### Arguments + +`user` - The address of the user. +`eth_rpc_url` - The URL of the Ethereum RPC node. +`network` - The network on which the balance will be checked. + +#### Returns + +- `Result` - The balance of the user in the payment service. + +#### Errors + +- `EthereumProviderError` if there is an error in the connection with the RPC provider. +- `EthereumCallError` if there is an error in the Ethereum call.