Skip to content

Commit

Permalink
feat: document cast mktx (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
ay committed Mar 14, 2024
1 parent 90bcd80 commit a6afa27
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
- [cast publish](./reference/cast/cast-publish.md)
- [cast receipt](./reference/cast/cast-receipt.md)
- [cast send](./reference/cast/cast-send.md)
- [cast mktx](./reference/cast/cast-mktx.md)
- [cast call](./reference/cast/cast-call.md)
- [cast rpc](./reference/cast/cast-rpc.md)
- [cast tx](./reference/cast/cast-tx.md)
Expand Down
75 changes: 75 additions & 0 deletions src/reference/cast/cast-mktx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
## cast mktx

### NAME

cast-mktx - Build and sign a transaction.

### SYNOPSIS

``cast mktx`` [*options*] *to* [*sig*] [*args...*]

### DESCRIPTION

Build and sign a transaction, without publishing it.

The destination (*to*) can be an ENS name or an address.

{{#include sig-description.md}}

### OPTIONS

{{#include ../common/transaction-options.md}}

`--create` *code* [*sig* *args...*]
    Deploy a contract by specifying raw bytecode, in place of specifying a *to* address.

{{#include ../common/wallet-options-raw.md}}

{{#include ../common/wallet-options-keystore.md}}

{{#include ../common/wallet-options-hardware.md}}

{{#include ../common/rpc-options.md}}

{{#include ../common/etherscan-options.md}}

{{#include common-options.md}}

### EXAMPLES

1. Sign a transaction that sends some ether to Vitalik using your Ledger:
```sh
cast mktx --ledger vitalik.eth --value 0.1ether
```

2. Sign a transaction that calls `deposit(address token, uint256 amount)` on a contract:
```sh
cast mktx --ledger 0x... "deposit(address,uint256)" 0x... 1
```

3. Sign a transaction that calls a function that expects a `struct`:

```solidity
contract Test {
struct MyStruct {
address addr;
uint256 amount;
}
function myfunction(MyStruct memory t) public pure {}
}
```

Structs are encoded as tuples (see [struct encoding](../../misc/struct-encoding.md))

```sh
cast mktx 0x... "myfunction((address,uint256))" "(0x...,1)"
```

4. Sign a transaction with hex data in the `input` field of the transaction object:
```sh
cast mktx 0x... 0x68656c6c6f20776f726c64
```

### SEE ALSO

[cast](./cast.md), [cast publish](./cast-publish.md), [cast send](./cast-send.md), [struct encoding](../../misc/struct-encoding.md)
2 changes: 1 addition & 1 deletion src/reference/cast/cast-publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ Publish a raw pre-signed transaction to the network.

### SEE ALSO

[cast](./cast.md), [cast call](./cast-call.md), [cast send](./cast-send.md), [cast receipt](./cast-receipt.md)
[cast](./cast.md), [cast call](./cast-call.md), [cast send](./cast-send.md), [cast receipt](./cast-receipt.md), [cast mktx](./cast-mktx.md)
2 changes: 1 addition & 1 deletion src/reference/cast/cast-send.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ The destination (*to*) can be an ENS name or an address.

### SEE ALSO

[cast](./cast.md), [cast call](./cast-call.md), [cast publish](./cast-publish.md), [cast receipt](./cast-receipt.md), [struct encoding](../../misc/struct-encoding.md)
[cast](./cast.md), [cast call](./cast-call.md), [cast publish](./cast-publish.md), [cast receipt](./cast-receipt.md), [cast mktx](./cast-mktx.md), [struct encoding](../../misc/struct-encoding.md)
1 change: 1 addition & 0 deletions src/reference/cast/transaction-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- [cast publish](./cast-publish.md)
- [cast receipt](./cast-receipt.md)
- [cast send](./cast-send.md)
- [cast mktx](./cast-mktx.md)
- [cast call](./cast-call.md)
- [cast rpc](./cast-rpc.md)
- [cast tx](./cast-tx.md)
Expand Down

0 comments on commit a6afa27

Please sign in to comment.