@openfort/openfort-node 0.9.1 → 0.9.3
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/CHANGELOG.md +14 -0
- package/dist/index.d.mts +335 -548
- package/dist/index.d.ts +335 -548
- package/dist/index.js +139 -177
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -164
- package/dist/index.mjs.map +1 -1
- package/examples/evm/delegation/sendTransaction.ts +34 -0
- package/openapi.json +28 -637
- package/package.json +16 -16
- package/tsconfig.json +1 -1
- package/pnpm-workspace.yaml +0 -11
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import 'dotenv/config'
|
|
2
|
+
import Openfort from '@openfort/openfort-node'
|
|
3
|
+
|
|
4
|
+
const openfort = new Openfort(process.env.OPENFORT_API_KEY!, {
|
|
5
|
+
walletSecret: process.env.OPENFORT_WALLET_SECRET!,
|
|
6
|
+
})
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// 1. Create an EVM backend account
|
|
10
|
+
const account = await openfort.accounts.evm.backend.create()
|
|
11
|
+
// const signedAuthorization = await account.sign({ hash: authHash })
|
|
12
|
+
|
|
13
|
+
const interactions = [
|
|
14
|
+
{ to: '0x0000000000000000000000000000000000000000', value: '0', data: '0x' },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
console.log("=== Full delegation + signing flow via sendTransaction() ===")
|
|
18
|
+
// 2. First call: account is new -> delegates via EIP-7702, then sends the transaction
|
|
19
|
+
const result = await openfort.accounts.evm.backend.sendTransaction({
|
|
20
|
+
account: account,
|
|
21
|
+
chainId: 84532, // Base Sepolia
|
|
22
|
+
interactions,
|
|
23
|
+
})
|
|
24
|
+
console.log("First tx", result.response?.transactionHash)
|
|
25
|
+
|
|
26
|
+
// 3. Second call: account is already delegated -> skips delegation, sends directly
|
|
27
|
+
const result2 = await openfort.accounts.evm.backend.sendTransaction({
|
|
28
|
+
account: account,
|
|
29
|
+
chainId: 84532,
|
|
30
|
+
interactions,
|
|
31
|
+
})
|
|
32
|
+
console.log("Second tx", result2.response?.transactionHash)
|
|
33
|
+
|
|
34
|
+
|