@tevm/voltaire 0.2.25 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,46 @@
|
|
|
7
7
|
<img width="512" height="512" alt="voltaire-logo" src="https://github.com/user-attachments/assets/409b49cb-113b-4b76-989d-762f6294e26a" />
|
|
8
8
|
</a>
|
|
9
9
|
</h1>
|
|
10
|
+
<strong>For application development, we recommend <a href="./voltaire-effect">voltaire-effect</a> — Effect.ts integration with typed errors, services, and composable operations.</strong>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## voltaire-effect: Production-Ready Contract Interactions
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Effect } from 'effect'
|
|
17
|
+
import {
|
|
18
|
+
ContractRegistryService,
|
|
19
|
+
makeContractRegistry,
|
|
20
|
+
Provider,
|
|
21
|
+
HttpTransport
|
|
22
|
+
} from 'voltaire-effect'
|
|
23
|
+
|
|
24
|
+
const Contracts = makeContractRegistry({
|
|
25
|
+
USDC: { abi: erc20Abi, address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' },
|
|
26
|
+
WETH: { abi: erc20Abi, address: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' },
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const program = Effect.gen(function* () {
|
|
30
|
+
const { USDC, WETH } = yield* ContractRegistryService
|
|
31
|
+
const usdcBalance = yield* USDC.read.balanceOf(userAddress)
|
|
32
|
+
const wethBalance = yield* WETH.read.balanceOf(userAddress)
|
|
33
|
+
return { usdcBalance, wethBalance }
|
|
34
|
+
}).pipe(
|
|
35
|
+
Effect.retry({ times: 3 }),
|
|
36
|
+
Effect.timeout('10 seconds'),
|
|
37
|
+
Effect.provide(Contracts),
|
|
38
|
+
Effect.provide(Provider),
|
|
39
|
+
Effect.provide(HttpTransport('https://eth.llamarpc.com'))
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Features:** Typed errors, dependency injection, composable operations, tree-shakeable.
|
|
44
|
+
|
|
45
|
+
[Get started with voltaire-effect →](./voltaire-effect)
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<div align="center">
|
|
10
50
|
<sup>
|
|
11
51
|
<a href="https://www.npmjs.com/package/@tevm/voltaire">
|
|
12
52
|
<img src="https://img.shields.io/npm/v/@tevm/voltaire.svg" alt="npm version" />
|
package/package.json
CHANGED