-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbatch.ts
37 lines (32 loc) · 1.01 KB
/
batch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Wallet } from 'ethers'
import { parseEther } from 'ethers/lib/utils'
import { FuseSDK } from '../src'
import Variables from '../src/constants/variables'
const main = async () => {
const credentials = new Wallet(process.env.PRIVATE_KEY as string)
const publicApiKey = process.env.PUBLIC_API_KEY as string
const fuseSDK = await FuseSDK.init(publicApiKey, credentials, {
withPaymaster: true,
})
// You can use any other "to" address and any other "value"
const to = 'YOUR_RECEIVER_ADDRESS'
const value = parseEther('0.001')
const data = Uint8Array.from([])
const txOptions = {
...Variables.DEFAULT_TX_OPTIONS,
useNonceSequence: true,
}
const res = await fuseSDK.executeBatch(
[
{ to, value, data },
{ to, value, data },
{ to, value, data },
],
txOptions
)
console.log(`UserOpHash: ${res?.userOpHash}`)
console.log('Waiting for transaction...')
const receipt = await res?.wait()
console.log('Transaction Hash:', receipt?.transactionHash)
}
main()