diff --git a/Makefile b/Makefile index 2bfc0a7..965b5c2 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,9 @@ install: clean foundryup forge install +tx: + npx create-safe-tx + hash: forge script script/HashData.s.sol diff --git a/README.md b/README.md index c3685be..67d66a9 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,18 @@ - Run `make` to initialize the repository. - Create a `.env` file from the template [`.env.example`](./.env.example) file. - Use the environment variable `SAFE_NONCE` to override a transaction's nonce. Leave it blank to use the default, latest Safe nonce. + - Use the environment variable `FOUNDRY_ETH_RPC_URL` to customize the RPC endpoint used. This is useful to interact with a Safe deployed on another chain than Ethereum mainnet (the default one). -You can customize the RPC url used in [`foundry.tml`](./foundry.toml) under the `rpc_endpoint` section. This is useful if your Safe is not deployed on mainnet (which is the default chain used). +### Build a Safe tx + +- Run `make tx` and follow the steps to create a Safe transaction using [create-safe-tx](https://github.com/morpho-labs/create-safe-tx); OR +- Put the transaction's raw data in `data/tx.json` ### Sign a Safe tx -1. Put the transaction's raw data in `data/tx.json` -2. Hash the transaction's raw data: `make hash` -3. To sign the data with a Ledger, run: `make sign:ledger` -4. Share the content of `data/signatures.txt` with the signer who will execute the transaction on the Safe +1. Hash the transaction's raw data: `make hash` +2. To sign the data with a Ledger, run: `make sign:ledger` +3. Share the content of `data/signatures.txt` with the signer who will execute the transaction on the Safe ### Batch signatures and execute transaction @@ -26,6 +29,7 @@ You can customize the RPC url used in [`foundry.tml`](./foundry.toml) under the ### Wallet support With `make sign` & `make exec`, one can also use any other wallet provider available with `cast`: + - `make cmd:interactive` to input the private key to the command prompt - `make cmd:ledger` to use a Ledger - `make cmd:trezor` to use a Trezor @@ -36,14 +40,14 @@ With `make sign` & `make exec`, one can also use any other wallet provider avail ```json { - "to": "0x0000000000000000000000000000000000000000", - "value": 0, - "data": "0x", // The raw tx data - "operation": 0, // 0 for a call, 1 for a delegatecall - "safeTxGas": 0, - "baseGas": 0, - "gasPrice": 0, - "gasToken": "0x0000000000000000000000000000000000000000", // Indicates the tx will consume the chain's default gas token (ETH on mainnet) - "refundReceiver": "0x0000000000000000000000000000000000000000" // Indicates the tx's refund receiver will be the address executing the tx + "to": "0x0000000000000000000000000000000000000000", + "value": "0", // The tx value (in ETH), must be a string + "data": "0x", // The raw tx data, must start with 0x + "operation": 0, // 0 for a call, 1 for a delegatecall + "safeTxGas": 0, + "baseGas": 0, + "gasPrice": 0, + "gasToken": "0x0000000000000000000000000000000000000000", // Indicates the tx will consume the chain's default gas token (ETH on mainnet) + "refundReceiver": "0x0000000000000000000000000000000000000000" // Indicates the tx's refund receiver will be the address executing the tx } ``` diff --git a/data/template.json b/data/template.json index 644870c..4797d61 100644 --- a/data/template.json +++ b/data/template.json @@ -1,6 +1,6 @@ { "to": "0x0000000000000000000000000000000000000000", - "value": 0, + "value": "0", "data": "0x", "operation": 0, "safeTxGas": 0, diff --git a/script/SafeTxDataBuilder.sol b/script/SafeTxDataBuilder.sol index c1ba5fb..5d5d283 100644 --- a/script/SafeTxDataBuilder.sol +++ b/script/SafeTxDataBuilder.sol @@ -54,7 +54,7 @@ contract SafeTxDataBuilder is Script, SignatureDecoder { string memory json = vm.readFile(TX_FILE); txData.to = json.readAddress("$.to"); - txData.value = json.readUint("$.value"); + txData.value = json.readUint("$.value"); // TODO: this is actually a string. Check if it works properly txData.data = json.readBytes("$.data"); txData.operation = Enum.Operation(json.readUint("$.operation")); txData.safeTxGas = json.readUint("$.safeTxGas");