forked from fuseio/fusebox-web-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstake_tokens.ts
More file actions
26 lines (23 loc) · 861 Bytes
/
Copy pathstake_tokens.ts
File metadata and controls
26 lines (23 loc) · 861 Bytes
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
import { Wallet } from 'ethers'
import { FuseSDK, StakeRequestBody } 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,
})
const nativeTokenAddress = Variables.NATIVE_TOKEN_ADDRESS
const res = await fuseSDK.stakeToken(
new StakeRequestBody({
accountAddress: fuseSDK.wallet.getSender(),
tokenAmount: '0.01',
tokenAddress: nativeTokenAddress,
})
)
console.log(`UserOpHash: ${res?.userOpHash}`)
console.log('Waiting for transaction...')
const ev = await res?.wait()
console.log(`Transaction hash: https://explorer.fuse.io/tx/${ev?.transactionHash}`)
}
main()