-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfront-end
More file actions
111 lines (92 loc) · 2.41 KB
/
front-end
File metadata and controls
111 lines (92 loc) · 2.41 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { JsonRpcProvider } from 'ethers';
import { getDefaultProvider, Network } from "@lens-network/sdk/ethers";
import { ethers } from "ethers";
import { ThirdwebProvider } from "thirdweb/react";
import App from "./App";
function Main() {
return (
<ThirdwebProvider>
<App />
</ThirdwebProvider>
);
}
export default Main;
// src/app.tsx
import { client } from "./client";
import { ConnectButton } from "thirdweb/react";
function App() {
return (
<div>
<ConnectButton client={client} />
</div>
);
}
import { useActiveAccount, useWalletBalance } from "thirdweb/react";
export default function App() {
const account = useActiveAccount();
const { data: balance, isLoading } = useWalletBalance({
client,
chain,
address: account.address,
});
return (
<div>
<p>Wallet address: {account.address}</p>
<p>
Wallet balance: {balance?.displayValue} {balance?.symbol}
</p>
</div>
);
}
import { client } from "./client";
import { getContract } from "thirdweb";
import { sepolia } from "thirdweb/chains";
import { useReadContract } from "thirdweb/react";
const contract = getContract({
client,
address: "0x...",
chain: sepolia,
});
export default function App() {
const { data, isLoading } = useReadContract({
contract,
method: "function tokenURI(uint256 tokenId) returns (string)",
params: [1n], // type safe params
});
return (
<div>
<p>Token URI: {data}</p>
</div>
);
}
import { client } from "./client";
import { getContract } from "thirdweb";
import { sepolia } from "thirdweb/chains";
import { useReadContract } from "thirdweb/react";
import { getOwnedNFTs } from "thirdweb/extensions/erc721";
const contract = getContract({
client,
address: "0x...",
chain: sepolia,
});
export default function App() {
const { data: ownedNFTs } = useReadContract(getOwnedNFTs, {
contract,
address: "0x...",
});
return (
<div>
<p>Owned NFTs: {ownedNFTs}</p>
</div>
);
}
// Connect to the Ethereum network
const provider = new JsonRpcProvider("https://lens-sepolia.g.alchemy.com/v2/08O747QY_FATMPHKp288jtVdC4v77wMm");
// Get block by number
const blockNumber = "latest";
const block = await provider.getBlock(blockNumber);
console.log(block);
// Lens Network (L2)
export const lensProvider = getDefaultProvider(Network.Testnet);
// Ethereum L1
export const ethProvider = ethers.getDefaultProvider("sepolia");