-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
79 lines (71 loc) · 2.27 KB
/
Copy pathindex.ts
File metadata and controls
79 lines (71 loc) · 2.27 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import {
createMeeClient,
getDefaultMeeGasTank,
getDefaultMEENetworkApiKey,
getDefaultMEENetworkUrl,
getMEEVersion,
MEEVersion,
toMultichainNexusAccount
} from "@biconomy/abstractjs";
import { createWalletClient, http } from "viem";
import { generatePrivateKey, privateKeyToAccount } from "viem/accounts";
import { spicy } from "viem/chains";
async function main() {
/**
* Creates an MEE client loaded with the EOA account
*/
const privateKey = generatePrivateKey();
const signer = createWalletClient({
chain: spicy, // loads Chiliz Spicy Testnet chain config
transport: http(),
account: privateKeyToAccount(privateKey)
});
const smartAccount = await toMultichainNexusAccount({
signer: signer.account,
chainConfigurations: [
{
chain: spicy,
transport: http(),
version: getMEEVersion(MEEVersion.V1_1_0)
}
]
});
const isStaging = true; // select staging environment for testnet access
const meeClient = await createMeeClient({
account: smartAccount,
url: getDefaultMEENetworkUrl(isStaging),
apiKey: getDefaultMEENetworkApiKey(isStaging)
});
/**
* Builds a dummy instruction that does nothing
*/
const dummyInstruction = await smartAccount.build({
type: "default",
data: {
calls: [{
to: "0x0000000000000000000000000000000000000000",
value: BigInt(0),
data: "0x",
gasLimit: 20000n,
}],
chainId: spicy.id
},
});
/**
* Executes the dummy instruction with MEE client.
* Result will contain the MEE hash which can be used to get the receipt on the MEEScan:
* https://meescan.biconomy.io/
*
* NOTE: Make sure to select staging environment on the MEEScan settings page.
*/
const result = await meeClient.execute({
instructions: [dummyInstruction],
sponsorship: true,
sponsorshipOptions: {
url: getDefaultMEENetworkUrl(isStaging),
gasTank: getDefaultMeeGasTank(isStaging)
},
});
console.log(result);
}
main().then(console.log).catch(console.log);