From 2d9b1191c277b74ca57d05badaf74889cc3a6f56 Mon Sep 17 00:00:00 2001 From: denbite Date: Mon, 7 Oct 2024 17:36:34 +0200 Subject: [PATCH] docs: fill Readme file --- README.md | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 99 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f2f6183..10eccb8 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,26 @@ -# near_eth_tx +# Near Multi-Chain DAO Governance Contract -cargo-near-new-project-description +The smart contract is designed to act as an intermediary between Decentralized Organizations (such as DAOs or Multisig contracts) and a Multi-Party Computation (MPC) contract. Its primary purpose is to streamline the governance process for DAO councils by allowing them to vote on proposals once and automatically generate the necessary signatures for the same payload across multiple Ethereum Virtual Machine (EVM) compatible chains—differing only by the chain ID. + +## Environments + +Currently, there're 2 environments: + +1. Testnet: `abstract-dao.testnet` +2. Dev (unstable): `dev.abstract-dao.testnet` ## How to Build Locally? Install [`cargo-near`](https://github.com/near/cargo-near) and run: ```bash -cargo near build +cargo near build --no-abi --no-docker ``` ## How to Test Locally? +The following command runs both unit and integration tests: + ```bash cargo test ``` @@ -22,9 +31,95 @@ Deployment is automated with GitHub Actions CI/CD pipeline. To deploy manually, install [`cargo-near`](https://github.com/near/cargo-near) and run: ```bash -cargo near deploy +cargo near deploy --no-abi +``` + +## How To Use? + +1. A proposal is created and submitted to the organization (DAO or multisig) for review. + +2. Members cast their votes on the proposal (either approve, or reject) + +3. Once approved, the institution turns to the Governance Contract to record their intention to generate a signature for a specific payload and grant permission to some account to execute it + +4. For each target EVM-compatible chain, the eligible account interacts with the Governance Contract to construct a signature specific to that chain + +## API + +To execute a command from the example, install [`near-cli`](https://near.cli.rs) + +### `register_signature_request()` + +This is one of the main functions of the contract. It records user's intention to generate a signature for a specific payload and grants permission to some account to execute it later + +```rs +pub fn register_signature_request(&mut self, request: InputRequest) -> RequestId ``` +#### Example + +```bash +near contract call-function as-transaction abstract-dao.testnet register_signature_request json-args '{ + "request": { + "allowed_account_id": "", + "derivation_seed_number": 0, + "transaction_payload": { + "to": "0xe2a01146FFfC8432497ae49A7a6cBa5B9Abd71A3", + "nonce": "0", + "function_data": { + "function_abi": { + "inputs": [ + { + "internalType": "uint256", + "name": "_num", + "type": "uint256" + } + ], + "name": "set", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + "arguments": [ + { + "Uint": "A97" + } + ] + } + } + } +}' prepaid-gas '100.0 Tgas' attached-deposit '0.1 NEAR' sign-as network-config testnet +``` + +- `` is the user who will be allowed to get signature later +- `` is the institution's account for which signature is generated +- Integer arguments must be base64 encoded + +### `get_signature()` + +This is one of the main functions of the contract. It validates predecessor's permissions, converts payload into EIP-1559 transaction, and transmits further to MPC Contract where the signature is created + +```rs +pub fn get_signature(&mut self, request_id: RequestId, other_payload: OtherEip1559TransactionPayload) -> Promise +``` + +#### Example + +```bash +near contract call-function as-transaction abstract-dao.testnet get_signature json-args '{ + "request_id": , + "other_payload": { + "chain_id": 11155111, + "max_fee_per_gas": "111551114121", + "max_priority_fee_per_gas": "294111551111" + } +}' prepaid-gas '300.0 Tgas' attached-deposit '0.05 NEAR' sign-as network-config testnet +``` + +- `` is returned in response of `register_signature_request()` +- `` must have permission to run `get_signature()`, otherwise it will throw forbidden error +- Prepaid gas must be bigger than 250TGas + ## Useful Links - [cargo-near](https://github.com/near/cargo-near) - NEAR smart contract development toolkit for Rust