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
// Write (async - enqueued on EVM_QUEUE default:evm-send, see https://laravel-evm.farbcode.net/basic-usage#writes-async-transactions for more information)
This page provides the minimal steps to read (eth_call) and write (async EIP-1559) contract functions using the Laravel EVM package. For events, log filtering and full API details see the Advanced Usage and Reference pages.
3
+
This page provides the minimal steps to read (eth_call) and write (async EIP-1559) contract functions using the Laravel
4
+
EVM package. For events, log filtering and full API details see the Advanced Usage and Reference pages.
Writes enqueue a `SendTransaction` job. You need a running queue worker for progress (unless using the sync queue driver).
64
+
65
+
Writes enqueue a `SendTransaction` job. You need a running queue worker for progress (unless using the sync queue
66
+
driver).
52
67
53
68
### Transaction Job Lifecycle
69
+
54
70
The queued job executes these steps:
71
+
55
72
1. ABI encode function + args.
56
73
2. Gas estimation with padding.
57
74
3. Nonce retrieval (preventing collisions).
@@ -60,32 +77,108 @@ The queued job executes these steps:
60
77
6. Broadcast to RPC.
61
78
7. Receipt polling until mined or timeout.
62
79
8. Optional fee bump & replacement attempts.
63
-
Events provide visibility: `TxQueued`, `TxBroadcasted`, `TxReplaced`, `TxMined`, `TxFailed`.
80
+
Events provide visibility: `TxQueued`, `TxBroadcasted`, `TxReplaced`, `TxMined`, `TxFailed`.
64
81
65
82
#### Common Write Pitfalls
83
+
66
84
- Stuck Pending: Increase priority fee.
67
85
- Nonce Errors: Ensure only one worker per signing address.
68
86
69
-
## Gas Estimation
87
+
### Queue Configuration & Workers
88
+
89
+
By default outgoing transactions are placed on the queue name defined in `config/evm.php` (config('evm.tx.queue'), .env:
90
+
`EVM_QUEUE`, default: `evm-send`). Ensure your `QUEUE_CONNECTION` (recommended: `redis`) is configured.
91
+
92
+
If you set the queue driver to `sync`, jobs execute inline and no worker is required. This is acceptable for local
93
+
experiments but not recommended in production (no concurrency control, risk of nonce clashes, blocking HTTP requests).
94
+
95
+
Start a dedicated worker for the send queue:
96
+
97
+
```bash
98
+
php artisan queue:work --queue=evm-send
99
+
```
100
+
101
+
**CRITICAL: Run exactly ONE worker process per signing address for the `evm-send` queue.** This guarantees strict nonce ordering. Multiple concurrent workers sharing the same private key will race nonces.
102
+
If you require higher throughput, add additional signing addresses rather than scaling processes for a single key.
103
+
104
+
### Horizon Example
105
+
106
+
When using Laravel Horizon, configure a separate supervisor for `evm-send`:
107
+
70
108
```php
71
-
$data = $contract->call('symbol')->raw(); // Example encoded data reuse
72
-
$gas = $contract->estimateGas($data);
109
+
// config/horizon.php (excerpt)
110
+
return [
111
+
'defaults' => [
112
+
// ...
113
+
114
+
'supervisor-2' => [
115
+
'connection' => 'redis',
116
+
'queue' => ['evm-send'],
117
+
'balance' => 'auto',
118
+
'autoScalingStrategy' => 'time',
119
+
'maxProcesses' => 1, // DO NOT raise for same signer; keep 1 to preserve nonce ordering
120
+
'maxTime' => 0,
121
+
'maxJobs' => 0,
122
+
'memory' => 128,
123
+
'tries' => 1,
124
+
'timeout' => 180,
125
+
'nice' => 0,
126
+
],
127
+
],
128
+
'environments' => [
129
+
'production' => [
130
+
// ...
131
+
'supervisor-2' => [
132
+
'maxProcesses' => 1,
133
+
],
134
+
],
135
+
'local' => [
136
+
// ...
137
+
'supervisor-2' => [
138
+
'maxProcesses' => 1,
139
+
],
140
+
],
141
+
],
142
+
];
73
143
```
74
-
Adds configurable padding to avoid underestimation.
144
+
Production can scale the default queue separately while keeping `evm-send` serialized.
0 commit comments