-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.mjs
More file actions
48 lines (38 loc) · 1.51 KB
/
script.mjs
File metadata and controls
48 lines (38 loc) · 1.51 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
import ethers from "ethers";
import { TESTNET_ADDRESS, CONTRACT_ABI, KOVAN_CHAIN_ID } from "./constants.mjs";
const main = async () => {
const receiver = "0xA73B9e90258cd779d3341D8f4eA2C793372F502a";
const startTime = 0;
const stopTime = 1000;
const tipValue = new ethers.BigNumber.from("1000000000000000000");
const privateKey =
"e8b9b155cbad4b7efe1a1c675305b3f6ed6af9123414e4f3382dddfdc0e94908";
const provider = new ethers.providers.JsonRpcProvider(
"https://opt-kovan.g.alchemy.com/v2/Ragjvftvm2NlbK7CPBVFvv5ha3GjjvsL"
);
let wallet = new ethers.Wallet(privateKey, provider);
// console.log("provider: ", provider);
const signer = await provider.getSigner();
const contract = new ethers.Contract(TESTNET_ADDRESS, CONTRACT_ABI, provider);
const contractWithSigner = contract.connect(wallet);
const profile = await contract.getAllProfiles();
console.log("profile: ", profile);
// const tipETH = await contractWithSigner.tipETH(receiver, { value: tipValue });
// const receipt = await tipETH.wait();
// console.log("tipETH: ", receipt);
const blockNumber = await provider.getBlockNumber();
const timestamp = (await provider.getBlock(blockNumber)).timestamp;
const endTimeStamp = timestamp + 10000000;
console.log("timestamps: ", timestamp, endTimeStamp);
const txn = await contractWithSigner.createETHStream(
receiver,
timestamp,
endTimeStamp,
{
value: tipValue,
}
);
const receipt = await txn.wait();
console.log("create txn: ", receipt);
};
main();