@corpus-core/colibri-stateless 0.4.10 → 0.5.0
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 +35 -1
- package/c4w.js +1 -1
- package/index.d.ts +2 -0
- package/index.js +18 -1
- package/package.json +1 -1
- package/transactionVerifier.d.ts +94 -0
- package/transactionVerifier.js +196 -0
- package/types.d.ts +1 -0
package/README.md
CHANGED
|
@@ -109,6 +109,32 @@ async function main() {
|
|
|
109
109
|
main().catch(console.error);
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
+
## Secure Transaction Verification
|
|
113
|
+
|
|
114
|
+
Protect your dApp from NPM supply-chain attacks and transaction manipulation:
|
|
115
|
+
|
|
116
|
+
```javascript
|
|
117
|
+
import { BrowserProvider } from "ethers";
|
|
118
|
+
import Colibri from "@corpus-core/colibri-stateless";
|
|
119
|
+
|
|
120
|
+
// 🛡️ Secure transactions with built-in verification
|
|
121
|
+
const client = new Colibri({
|
|
122
|
+
fallback_provider: window.ethereum, // MetaMask as Signer
|
|
123
|
+
verifyTransactions: true // Prevents transaction manipulation
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const provider = new BrowserProvider(client);
|
|
127
|
+
|
|
128
|
+
// Send transaction - automatically verified before broadcast
|
|
129
|
+
const tx = await provider.getSigner().sendTransaction({
|
|
130
|
+
to: "0x742d35cc6633C0532925a3b8D8C9C4e2F9",
|
|
131
|
+
value: "0x16345785d8a0000", // 0.1 ETH
|
|
132
|
+
gasLimit: "0x5208"
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
console.log("✅ Verified transaction:", tx.hash);
|
|
136
|
+
```
|
|
137
|
+
|
|
112
138
|
## Building proofs in you app.
|
|
113
139
|
|
|
114
140
|
If you don't want to use a remote Service building the proofs, you can also use Colibri directly to build the proof or to verify. A Proof is juzst a UInt8Array or just bytes. You write it in a file or package it in your application and verify whenever it is needed:
|
|
@@ -222,11 +248,19 @@ The constructor of the colibri client accepts a configuration-object, which may
|
|
|
222
248
|
```
|
|
223
249
|
|
|
224
250
|
|
|
225
|
-
- `fallback_provider`- a EIP 1193 Provider used as fallback for all requests which are not verifieable, like eth_sendTransaction.
|
|
251
|
+
- `fallback_provider`- a EIP 1193 Provider used as fallback for all requests which are not verifieable, like eth_sendTransaction. Also used for signing transactions when `verifyTransactions` is enabled.
|
|
226
252
|
```js
|
|
227
253
|
new Colibri({ fallback_provider: window.ethereum })
|
|
228
254
|
```
|
|
229
255
|
|
|
256
|
+
- `verifyTransactions`- if true, all eth_sendTransaction calls will be verified before broadcast to prevent transaction manipulation attacks. Requires `fallback_provider` to be set. (default: false)
|
|
257
|
+
```js
|
|
258
|
+
new Colibri({
|
|
259
|
+
fallback_provider: window.ethereum,
|
|
260
|
+
verifyTransactions: true
|
|
261
|
+
})
|
|
262
|
+
```
|
|
263
|
+
|
|
230
264
|
|
|
231
265
|
|
|
232
266
|
## Building
|