-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.js
More file actions
55 lines (45 loc) · 1.74 KB
/
demo.js
File metadata and controls
55 lines (45 loc) · 1.74 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
require('dotenv').config()
const { Network, Alchemy } = require('alchemy-sdk');
const ethers = require('ethers');
const VRFD20ContractBuilt = require("../build/contracts/VRFD20.json");
const config = {
apiKey: process.env.ALCHEMY_API_KEY,
network: Network.ETH_SEPOLIA,
};
const alchemyProvider = new Alchemy(config);
// console.log('alchemyProvider', alchemyProvider);
// Signer
const signer = new ethers.Wallet(process.env.MOONBASE_PRIVATE_KEY, alchemyProvider);
// console.log('signer', signer);
// Contract
const VRFD20DeployedAtAddress = '0xe22cdfA9d8C8e942B498696ef54584426d2f5Dd6';
const VRFD20Contract = new ethers.Contract(VRFD20DeployedAtAddress, VRFD20ContractBuilt.abi, signer);
// console.log('VRFD20Contract', VRFD20Contract);
// Example of using the call method
const main = async () => {
// Get the latest block
const latestBlock = await alchemyProvider.core.getBlockNumber();
console.log('latestBlock', latestBlock);
};
main();
// https://docs.alchemy.com/docs/interacting-with-a-smart-contract
// // Provider
// // https://docs.ethers.org/v6/api/providers/#WebSocketProvider
// const alchemyProvider = new ethers.AlchemyProvider(
// // _network: 11155111,
// // url=process.env.CHAINLINK_SEPOLIA_ENDPOINT,
// _network=Network.ETH_SEPOLIA,
// // "eth-sepolia",
// process.env.ALCHEMY_API_KEY
// );
// // Listen to all new pending transactions
// alchemy.ws.on(
// {
// method: "alchemy_pendingTransactions",
// fromAddress: "0x1dd907ABb024E17d196de0D7Fe8EB507b6cCaae7"
// },
// (res) => console.log('detected pending tx from account:', res),
// );
// // Interact with VRFD20
// const s_owner = await VRFD20Contract.s_owner();
// console.log("The s_owner is: ", s_owner);