-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexample.js
More file actions
35 lines (28 loc) · 1.04 KB
/
example.js
File metadata and controls
35 lines (28 loc) · 1.04 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
const {
deploy,
enableMockApi,
disableMockApi,
} = require("@any-sender/dev-tools");
const { any } = require("@any-sender/client");
const { ethers } = require("ethers");
const { parseEther } = require("ethers/utils");
const Ganache = require("ganache-core");
const run = async () => {
const ganache = Ganache.provider();
const provider = new ethers.providers.Web3Provider(ganache);
const user = provider.getSigner(0);
// deploy contracts needed for local development
await deploy.contracts(provider);
// enable the mock api
enableMockApi();
// wrap a signer with any.sender, since the mock API has been enabled
// it'll automatically get picked up by any.sender()
const userDot = any.sender(user);
// now you're ready to check your balance and relay transactions
console.log((await userDot.any.getBalance()).toString());
await (await userDot.any.deposit(parseEther("0.5"))).wait();
console.log((await userDot.any.getBalance()).toString());
// disable the mock api, since we dont need it any more
disableMockApi();
};
run();