@sei-js/create-sei 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -4
- package/dist/extensions/precompiles/src/components/default/index.tsx +44 -51
- package/dist/main.js +112 -34
- package/dist/templates/next-template/.env.example +1 -1
- package/dist/templates/next-template/README.md +57 -27
- package/dist/templates/next-template/biome.json +3 -4
- package/dist/templates/next-template/gitignore +41 -0
- package/dist/templates/next-template/next.config.mjs +12 -6
- package/dist/templates/next-template/package.json +36 -27
- package/dist/templates/next-template/public/brand/powered-by-sei-light.png +0 -0
- package/dist/templates/next-template/public/brand/sei-lockup-light.svg +7 -0
- package/dist/templates/next-template/public/brand/sei-mark.png +0 -0
- package/dist/templates/next-template/src/app/development/page.tsx +29 -30
- package/dist/templates/next-template/src/app/favicon.ico/route.ts +3 -0
- package/dist/templates/next-template/src/app/globals.css +40 -3
- package/dist/templates/next-template/src/app/layout.tsx +14 -13
- package/dist/templates/next-template/src/app/page.tsx +3 -3
- package/dist/templates/next-template/src/app/resources/page.tsx +34 -51
- package/dist/templates/next-template/src/app/resources/resources.ts +19 -32
- package/dist/templates/next-template/src/components/default/examples.ts +4 -7
- package/dist/templates/next-template/src/components/default/index.tsx +46 -46
- package/dist/templates/next-template/src/components/index.ts +3 -3
- package/dist/templates/next-template/src/components/landing/index.tsx +19 -97
- package/dist/templates/next-template/src/components/providers/index.ts +1 -1
- package/dist/templates/next-template/src/components/providers/providers.tsx +19 -25
- package/dist/templates/next-template/src/components/shell/index.ts +1 -1
- package/dist/templates/next-template/src/components/shell/shell.tsx +14 -7
- package/dist/templates/next-template/src/theme.ts +1 -0
- package/package.json +20 -9
- package/.rsyncignore +0 -11
- package/CHANGELOG.md +0 -131
- package/biome.json +0 -8
- package/dist/extensions/precompiles/package.json +0 -44
- package/dist/main.test.js +0 -34
- package/dist/templates/next-template/public/favicon.ico +0 -0
- package/extensions/precompiles/package.json +0 -44
- package/extensions/precompiles/src/components/default/index.tsx +0 -201
- package/jest.config.js +0 -14
- package/src/main.test.ts +0 -38
- package/src/main.ts +0 -159
- package/templates/next-template/.env.example +0 -8
- package/templates/next-template/.eslintrc.json +0 -1
- package/templates/next-template/.nvmrc +0 -1
- package/templates/next-template/README.md +0 -54
- package/templates/next-template/biome.json +0 -56
- package/templates/next-template/next-env.d.ts +0 -5
- package/templates/next-template/next.config.mjs +0 -17
- package/templates/next-template/package.json +0 -46
- package/templates/next-template/postcss.config.mjs +0 -6
- package/templates/next-template/public/favicon.ico +0 -0
- package/templates/next-template/src/app/development/page.tsx +0 -260
- package/templates/next-template/src/app/globals.css +0 -16
- package/templates/next-template/src/app/layout.tsx +0 -30
- package/templates/next-template/src/app/page.tsx +0 -10
- package/templates/next-template/src/app/resources/page.tsx +0 -175
- package/templates/next-template/src/app/resources/resources.ts +0 -56
- package/templates/next-template/src/components/default/examples.ts +0 -63
- package/templates/next-template/src/components/default/index.tsx +0 -402
- package/templates/next-template/src/components/index.ts +0 -3
- package/templates/next-template/src/components/landing/index.tsx +0 -155
- package/templates/next-template/src/components/providers/index.ts +0 -1
- package/templates/next-template/src/components/providers/providers.tsx +0 -108
- package/templates/next-template/src/components/shell/index.ts +0 -1
- package/templates/next-template/src/components/shell/shell.tsx +0 -88
- package/templates/next-template/tailwind.config.js +0 -5
- package/templates/next-template/tsconfig.json +0 -27
- package/tsconfig.json +0 -19
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
import { developerResources, socialLinks } from '@/app/resources/resources';
|
|
2
|
-
import { Shell } from '@/components';
|
|
3
|
-
import { Card, Code, Container, Group, Paper, SimpleGrid, Stack, Text, ThemeIcon, Title } from '@mantine/core';
|
|
4
|
-
import { IconBook, IconRobot, IconTerminal } from '@tabler/icons-react';
|
|
5
|
-
|
|
6
|
-
export default function ResourcesPage() {
|
|
7
|
-
return (
|
|
8
|
-
<Shell>
|
|
9
|
-
<Container size="lg" py="xl">
|
|
10
|
-
<Stack gap="xl">
|
|
11
|
-
{/* Header */}
|
|
12
|
-
<div>
|
|
13
|
-
<Group gap="md" align="center" mb="lg">
|
|
14
|
-
<ThemeIcon size={48} radius="md" c="grape" variant="light">
|
|
15
|
-
<IconBook size={24} />
|
|
16
|
-
</ThemeIcon>
|
|
17
|
-
<div>
|
|
18
|
-
<Title order={1} fw={700} c="gray.9">
|
|
19
|
-
Developer Resources
|
|
20
|
-
</Title>
|
|
21
|
-
<Text size="lg" c="gray.6" mt={4}>
|
|
22
|
-
Everything you need to build on Sei. Documentation, tools, community links, and development guides.
|
|
23
|
-
</Text>
|
|
24
|
-
</div>
|
|
25
|
-
</Group>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
{/* Documentation & Tools */}
|
|
29
|
-
<Card shadow="sm" padding="xl" radius="lg" withBorder>
|
|
30
|
-
<Stack gap="lg">
|
|
31
|
-
<Title order={2} size="h3" fw={600} c="gray.8">
|
|
32
|
-
📚 Documentation & Tools
|
|
33
|
-
</Title>
|
|
34
|
-
<SimpleGrid cols={{ base: 1, sm: 2, lg: 2 }} spacing="lg">
|
|
35
|
-
{developerResources.map(({ title, description, href, icon: Icon, color }) => (
|
|
36
|
-
<Card key={title} withBorder radius="lg" p="xl" component="a" href={href} target="_blank" rel="noreferrer" shadow="sm">
|
|
37
|
-
<Group align="flex-start" wrap="nowrap" gap="md">
|
|
38
|
-
<ThemeIcon variant="light" color={color} size={40} radius="md">
|
|
39
|
-
<Icon size={22} />
|
|
40
|
-
</ThemeIcon>
|
|
41
|
-
<Stack gap={6} flex={1}>
|
|
42
|
-
<Text fw={600} size="lg" c="gray.9">
|
|
43
|
-
{title}
|
|
44
|
-
</Text>
|
|
45
|
-
<Text size="sm" c="dimmed" lh={1.5}>
|
|
46
|
-
{description}
|
|
47
|
-
</Text>
|
|
48
|
-
</Stack>
|
|
49
|
-
</Group>
|
|
50
|
-
</Card>
|
|
51
|
-
))}
|
|
52
|
-
</SimpleGrid>
|
|
53
|
-
</Stack>
|
|
54
|
-
</Card>
|
|
55
|
-
|
|
56
|
-
{/* MCP Server */}
|
|
57
|
-
<Card shadow="sm" padding="xl" radius="lg" withBorder>
|
|
58
|
-
<Stack gap="lg">
|
|
59
|
-
<Title order={2} size="h3" fw={600} c="gray.8">
|
|
60
|
-
🤖 AI Development Tools
|
|
61
|
-
</Title>
|
|
62
|
-
<Card withBorder radius="lg" p="xl" shadow="sm">
|
|
63
|
-
<Stack gap="lg">
|
|
64
|
-
<Stack gap="xs">
|
|
65
|
-
<Group gap="md">
|
|
66
|
-
<ThemeIcon size={40} radius="md" color="orange" variant="light">
|
|
67
|
-
<IconRobot size={20} />
|
|
68
|
-
</ThemeIcon>
|
|
69
|
-
<Title order={4} fw={600} c="gray.9">
|
|
70
|
-
Sei MCP Server
|
|
71
|
-
</Title>
|
|
72
|
-
</Group>
|
|
73
|
-
<Text size="sm" c="dimmed" lh={1.5} maw={500}>
|
|
74
|
-
Teach your IDE or LLM how to be an expert on Sei through the Model Context Protocol (MCP).
|
|
75
|
-
</Text>
|
|
76
|
-
</Stack>
|
|
77
|
-
|
|
78
|
-
<Paper p="md" radius="md" withBorder bg="gray.0">
|
|
79
|
-
<Stack gap="sm">
|
|
80
|
-
<Group gap="xs">
|
|
81
|
-
<IconTerminal size={16} color="var(--mantine-color-gray-6)" />
|
|
82
|
-
<Text size="xs" fw={500} c="dimmed">
|
|
83
|
-
Configuration
|
|
84
|
-
</Text>
|
|
85
|
-
</Group>
|
|
86
|
-
<Code block bg="white" p="md">
|
|
87
|
-
{`{
|
|
88
|
-
"mcpServers": {
|
|
89
|
-
"sei": {
|
|
90
|
-
"command": "npx",
|
|
91
|
-
"args": ["-y", "@sei-js/mcp-server"]
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}`}
|
|
95
|
-
</Code>
|
|
96
|
-
</Stack>
|
|
97
|
-
</Paper>
|
|
98
|
-
|
|
99
|
-
<SimpleGrid cols={{ base: 1, sm: 2 }} spacing="md">
|
|
100
|
-
<Card withBorder radius="md" p="md" component="a" href="https://sei-js.docs.sei.io/mcp-server/quickstart" target="_blank" rel="noreferrer">
|
|
101
|
-
<Group gap="sm">
|
|
102
|
-
<ThemeIcon size={32} radius="md" color="orange" variant="light">
|
|
103
|
-
<IconBook size={16} />
|
|
104
|
-
</ThemeIcon>
|
|
105
|
-
<Stack gap={2} flex={1}>
|
|
106
|
-
<Text fw={600} size="sm" c="gray.9">
|
|
107
|
-
Quickstart Guide
|
|
108
|
-
</Text>
|
|
109
|
-
<Text size="xs" c="dimmed">
|
|
110
|
-
Get started with MCP setup
|
|
111
|
-
</Text>
|
|
112
|
-
</Stack>
|
|
113
|
-
</Group>
|
|
114
|
-
</Card>
|
|
115
|
-
<Card
|
|
116
|
-
withBorder
|
|
117
|
-
radius="md"
|
|
118
|
-
p="md"
|
|
119
|
-
component="a"
|
|
120
|
-
href="https://sei-js.docs.sei.io/mcp-server/environment-variables"
|
|
121
|
-
target="_blank"
|
|
122
|
-
rel="noreferrer"
|
|
123
|
-
>
|
|
124
|
-
<Group gap="sm">
|
|
125
|
-
<ThemeIcon size={32} radius="md" color="orange" variant="light">
|
|
126
|
-
<IconTerminal size={16} />
|
|
127
|
-
</ThemeIcon>
|
|
128
|
-
<Stack gap={2} flex={1}>
|
|
129
|
-
<Text fw={600} size="sm" c="gray.9">
|
|
130
|
-
Environment Variables
|
|
131
|
-
</Text>
|
|
132
|
-
<Text size="xs" c="dimmed">
|
|
133
|
-
Configure your setup
|
|
134
|
-
</Text>
|
|
135
|
-
</Stack>
|
|
136
|
-
</Group>
|
|
137
|
-
</Card>
|
|
138
|
-
</SimpleGrid>
|
|
139
|
-
</Stack>
|
|
140
|
-
</Card>
|
|
141
|
-
</Stack>
|
|
142
|
-
</Card>
|
|
143
|
-
|
|
144
|
-
{/* Community & Social */}
|
|
145
|
-
<Card shadow="sm" padding="xl" radius="lg" withBorder>
|
|
146
|
-
<Stack gap="lg">
|
|
147
|
-
<Title order={2} size="h3" fw={600} c="gray.8">
|
|
148
|
-
🌐 Community & Social
|
|
149
|
-
</Title>
|
|
150
|
-
<SimpleGrid cols={{ base: 1, sm: 2, lg: 3 }} spacing="lg">
|
|
151
|
-
{socialLinks.map(({ title, description, href, icon: Icon, color }) => (
|
|
152
|
-
<Card key={title} withBorder radius="lg" p="lg" component="a" href={href} target="_blank" rel="noreferrer" shadow="sm">
|
|
153
|
-
<Group align="flex-start" wrap="nowrap" gap="md">
|
|
154
|
-
<ThemeIcon variant="light" color={color === 'dark' ? 'gray' : (color as any)} size={36} radius="md">
|
|
155
|
-
<Icon size={20} />
|
|
156
|
-
</ThemeIcon>
|
|
157
|
-
<Stack gap={4} flex={1}>
|
|
158
|
-
<Text fw={600} c="gray.9">
|
|
159
|
-
{title}
|
|
160
|
-
</Text>
|
|
161
|
-
<Text size="sm" c="dimmed" lh={1.4}>
|
|
162
|
-
{description}
|
|
163
|
-
</Text>
|
|
164
|
-
</Stack>
|
|
165
|
-
</Group>
|
|
166
|
-
</Card>
|
|
167
|
-
))}
|
|
168
|
-
</SimpleGrid>
|
|
169
|
-
</Stack>
|
|
170
|
-
</Card>
|
|
171
|
-
</Stack>
|
|
172
|
-
</Container>
|
|
173
|
-
</Shell>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { IconBook, IconBrandTelegram, IconBrandX, IconCode, IconPackage } from '@tabler/icons-react';
|
|
2
|
-
|
|
3
|
-
export const developerResources = [
|
|
4
|
-
{
|
|
5
|
-
title: 'Sei Docs',
|
|
6
|
-
description: 'Official protocol docs, guides, and references.',
|
|
7
|
-
href: 'https://docs.sei.io/',
|
|
8
|
-
icon: IconBook,
|
|
9
|
-
color: 'violet',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
title: '@sei-js docs',
|
|
13
|
-
description: 'SDKs, examples, templates, and tooling for Sei.',
|
|
14
|
-
href: 'https://sei-js.docs.sei.io/introduction',
|
|
15
|
-
icon: IconBook,
|
|
16
|
-
color: 'grape',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
title: 'Wagmi',
|
|
20
|
-
description: 'React hooks for Ethereum development.',
|
|
21
|
-
href: 'https://wagmi.sh/',
|
|
22
|
-
icon: IconCode,
|
|
23
|
-
color: 'blue',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
title: 'Viem',
|
|
27
|
-
description: 'TypeScript interface for Ethereum.',
|
|
28
|
-
href: 'https://viem.sh/',
|
|
29
|
-
icon: IconPackage,
|
|
30
|
-
color: 'green',
|
|
31
|
-
},
|
|
32
|
-
] as const;
|
|
33
|
-
|
|
34
|
-
export const socialLinks = [
|
|
35
|
-
{
|
|
36
|
-
title: 'Developer Telegram',
|
|
37
|
-
description: 'Chat with the community and get support.',
|
|
38
|
-
href: 'https://t.me/seinetwork',
|
|
39
|
-
icon: IconBrandTelegram,
|
|
40
|
-
color: 'cyan',
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
title: 'Sei on X',
|
|
44
|
-
description: 'Follow Sei Network updates on X (Twitter).',
|
|
45
|
-
href: 'https://x.com/SeiNetwork',
|
|
46
|
-
icon: IconBrandX,
|
|
47
|
-
color: 'dark',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: 'Sei Labs on X',
|
|
51
|
-
description: 'Follow Sei Labs announcements on X (Twitter).',
|
|
52
|
-
href: 'https://x.com/Sei_Labs',
|
|
53
|
-
icon: IconBrandX,
|
|
54
|
-
color: 'dark',
|
|
55
|
-
},
|
|
56
|
-
] as const;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Code examples for display
|
|
2
|
-
export const walletCodeExample = `// Import wallet hooks
|
|
3
|
-
import { useAccount, useDisconnect } from 'wagmi';
|
|
4
|
-
|
|
5
|
-
// Use the hooks
|
|
6
|
-
const { address, isConnected } = useAccount();
|
|
7
|
-
const { disconnect } = useDisconnect();
|
|
8
|
-
|
|
9
|
-
// Access wallet info
|
|
10
|
-
console.log('Connected:', isConnected);
|
|
11
|
-
console.log('Address:', address);
|
|
12
|
-
|
|
13
|
-
// Disconnect wallet
|
|
14
|
-
disconnect();`;
|
|
15
|
-
|
|
16
|
-
export const balanceCodeExample = `// Import hooks and utilities
|
|
17
|
-
import { useAccount, usePublicClient } from 'wagmi';
|
|
18
|
-
import { formatEther } from 'viem';
|
|
19
|
-
|
|
20
|
-
// Use the hooks
|
|
21
|
-
const { address } = useAccount();
|
|
22
|
-
const publicClient = usePublicClient();
|
|
23
|
-
|
|
24
|
-
// Get balance
|
|
25
|
-
const weiBalance = await publicClient.getBalance({ address });
|
|
26
|
-
const seiBalance = formatEther(weiBalance);`;
|
|
27
|
-
|
|
28
|
-
export const precompileCodeExample = `// Import Sei precompiles
|
|
29
|
-
import { VIEM_BANK_PRECOMPILE_ABI, BANK_PRECOMPILE_ADDRESS } from '@sei-js/precompiles';
|
|
30
|
-
import { usePublicClient } from 'wagmi';
|
|
31
|
-
import { type ReadContractParameters } from 'viem';
|
|
32
|
-
|
|
33
|
-
// Use the hook
|
|
34
|
-
const publicClient = usePublicClient();
|
|
35
|
-
|
|
36
|
-
// Call precompile
|
|
37
|
-
const readContractParams: ReadContractParameters = {
|
|
38
|
-
abi: VIEM_BANK_PRECOMPILE_ABI,
|
|
39
|
-
address: BANK_PRECOMPILE_ADDRESS,
|
|
40
|
-
functionName: 'supply',
|
|
41
|
-
args: ['usei']
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const result = await publicClient.readContract(readContractParams);`;
|
|
45
|
-
|
|
46
|
-
export const transactionCodeExample = `// Import transaction hooks
|
|
47
|
-
import { useSendTransaction, useWaitForTransactionReceipt } from 'wagmi';
|
|
48
|
-
import { parseEther } from 'viem';
|
|
49
|
-
|
|
50
|
-
// Use the hooks
|
|
51
|
-
const { data: hash, sendTransaction, isPending } = useSendTransaction();
|
|
52
|
-
const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({ hash });
|
|
53
|
-
|
|
54
|
-
// Example recipient address for demonstration
|
|
55
|
-
const exampleRecipient = '0x742d35cc6634C0532925a3b8D8C9C6c0C6c0C6c0';
|
|
56
|
-
|
|
57
|
-
// Send transaction
|
|
58
|
-
sendTransaction({
|
|
59
|
-
to: exampleRecipient,
|
|
60
|
-
value: parseEther(amount),
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// Transaction states: isPending → isConfirming → isConfirmed`;
|
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { CodeHighlight } from '@mantine/code-highlight';
|
|
4
|
-
import {
|
|
5
|
-
ActionIcon,
|
|
6
|
-
Alert,
|
|
7
|
-
Badge,
|
|
8
|
-
Button,
|
|
9
|
-
Card,
|
|
10
|
-
Code,
|
|
11
|
-
Collapse,
|
|
12
|
-
Container,
|
|
13
|
-
Flex,
|
|
14
|
-
Group,
|
|
15
|
-
Loader,
|
|
16
|
-
Paper,
|
|
17
|
-
Stack,
|
|
18
|
-
Text,
|
|
19
|
-
TextInput,
|
|
20
|
-
ThemeIcon,
|
|
21
|
-
Title,
|
|
22
|
-
} from '@mantine/core';
|
|
23
|
-
import { notifications } from '@mantine/notifications';
|
|
24
|
-
import { IconBulb, IconChevronDown, IconChevronUp, IconCoins, IconCopy, IconLogout, IconSend, IconWallet } from '@tabler/icons-react';
|
|
25
|
-
import { useState } from 'react';
|
|
26
|
-
import { formatEther, parseEther } from 'viem';
|
|
27
|
-
import { useAccount, useDisconnect, usePublicClient, useSendTransaction, useWaitForTransactionReceipt } from 'wagmi';
|
|
28
|
-
import { balanceCodeExample, transactionCodeExample, walletCodeExample } from './examples';
|
|
29
|
-
|
|
30
|
-
function Examples() {
|
|
31
|
-
const [balance, setBalance] = useState('');
|
|
32
|
-
const [recipient, setRecipient] = useState('');
|
|
33
|
-
const [amount, setAmount] = useState('');
|
|
34
|
-
|
|
35
|
-
// Code visibility toggles
|
|
36
|
-
const [showWalletCode, setShowWalletCode] = useState(false);
|
|
37
|
-
const [showBalanceCode, setShowBalanceCode] = useState(false);
|
|
38
|
-
const [showTransactionCode, setShowTransactionCode] = useState(false);
|
|
39
|
-
|
|
40
|
-
const publicClient = usePublicClient();
|
|
41
|
-
const { address, isConnected } = useAccount();
|
|
42
|
-
const { disconnect } = useDisconnect();
|
|
43
|
-
|
|
44
|
-
// Transaction hooks
|
|
45
|
-
const { data: hash, sendTransaction, isPending } = useSendTransaction();
|
|
46
|
-
const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({
|
|
47
|
-
hash,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const copyToClipboard = (text: string) => {
|
|
51
|
-
try {
|
|
52
|
-
navigator.clipboard.writeText(text).then(() => {
|
|
53
|
-
notifications.show({
|
|
54
|
-
title: 'Copied!',
|
|
55
|
-
message: 'Code copied to clipboard',
|
|
56
|
-
color: 'green',
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
} catch (err) {
|
|
60
|
-
console.error('Failed to copy text: ', err);
|
|
61
|
-
notifications.show({
|
|
62
|
-
title: 'Error',
|
|
63
|
-
message: 'Failed to copy to clipboard',
|
|
64
|
-
color: 'red',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const getBalanceWagmi = async () => {
|
|
70
|
-
if (!address || !publicClient) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
const weiBalance = await publicClient.getBalance({ address });
|
|
74
|
-
const seiBalance = formatEther(weiBalance);
|
|
75
|
-
setBalance(seiBalance);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
const sendSei = async () => {
|
|
79
|
-
if (!recipient || !amount) {
|
|
80
|
-
notifications.show({
|
|
81
|
-
title: 'Missing Information',
|
|
82
|
-
message: 'Please enter recipient address and amount',
|
|
83
|
-
color: 'orange',
|
|
84
|
-
});
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
try {
|
|
89
|
-
sendTransaction({
|
|
90
|
-
to: recipient as `0x${string}`,
|
|
91
|
-
value: parseEther(amount),
|
|
92
|
-
});
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.error('Transaction error:', error);
|
|
95
|
-
notifications.show({
|
|
96
|
-
title: 'Transaction Error',
|
|
97
|
-
message: 'Failed to send transaction',
|
|
98
|
-
color: 'red',
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return (
|
|
104
|
-
<Container size="xl" py="xl" pos="relative">
|
|
105
|
-
<Stack gap="xl">
|
|
106
|
-
{/* Header */}
|
|
107
|
-
<div>
|
|
108
|
-
<Group gap="md" align="center" mb="lg">
|
|
109
|
-
<ThemeIcon size={48} radius="md" c="blue" variant="light">
|
|
110
|
-
<IconBulb size={24} />
|
|
111
|
-
</ThemeIcon>
|
|
112
|
-
<div>
|
|
113
|
-
<Title order={1} fw={700} c="gray.9">
|
|
114
|
-
Interactive Examples
|
|
115
|
-
</Title>
|
|
116
|
-
<Text size="lg" c="gray.6" mt={4}>
|
|
117
|
-
Common blockchain development patterns with live code examples
|
|
118
|
-
</Text>
|
|
119
|
-
</div>
|
|
120
|
-
</Group>
|
|
121
|
-
</div>
|
|
122
|
-
|
|
123
|
-
{/* Wallet Connection Info */}
|
|
124
|
-
<Card shadow="xs" p="lg" radius="md" withBorder>
|
|
125
|
-
<Stack gap="md">
|
|
126
|
-
<Flex justify="space-between" align="flex-start">
|
|
127
|
-
<Stack gap="xs">
|
|
128
|
-
<Group gap="md">
|
|
129
|
-
<ThemeIcon size={40} radius="md" color="blue" variant="light">
|
|
130
|
-
<IconWallet size={20} />
|
|
131
|
-
</ThemeIcon>
|
|
132
|
-
<Title order={4} fw={600} c="gray.9">
|
|
133
|
-
Connected Wallet
|
|
134
|
-
</Title>
|
|
135
|
-
</Group>
|
|
136
|
-
<Text size="sm" c="gray.6">
|
|
137
|
-
Access wallet information using Wagmi's useAccount hook
|
|
138
|
-
</Text>
|
|
139
|
-
</Stack>
|
|
140
|
-
<Badge color="blue" variant="light" size="md" radius="md">
|
|
141
|
-
address
|
|
142
|
-
</Badge>
|
|
143
|
-
</Flex>
|
|
144
|
-
<Paper p="md" radius="md" withBorder bg="gray.0">
|
|
145
|
-
<Text size="xs" fw={500} c="gray.6">
|
|
146
|
-
Wallet Address
|
|
147
|
-
</Text>
|
|
148
|
-
<Flex justify="space-between" align="center">
|
|
149
|
-
<Code bg="white" p="xs">
|
|
150
|
-
{address || 'No wallet connected'}
|
|
151
|
-
</Code>
|
|
152
|
-
{isConnected && address && (
|
|
153
|
-
<Group gap="xs">
|
|
154
|
-
<ActionIcon variant="light" color="blue" size="sm" radius="md" onClick={() => copyToClipboard(address)} aria-label="Copy address">
|
|
155
|
-
<IconCopy size={14} />
|
|
156
|
-
</ActionIcon>
|
|
157
|
-
<ActionIcon variant="light" color="red" size="sm" radius="md" onClick={() => disconnect()} aria-label="Disconnect wallet">
|
|
158
|
-
<IconLogout size={14} />
|
|
159
|
-
</ActionIcon>
|
|
160
|
-
</Group>
|
|
161
|
-
)}
|
|
162
|
-
</Flex>
|
|
163
|
-
</Paper>
|
|
164
|
-
|
|
165
|
-
<Group justify="space-between" align="center" mt="sm">
|
|
166
|
-
<Button
|
|
167
|
-
variant="subtle"
|
|
168
|
-
color="gray"
|
|
169
|
-
size="sm"
|
|
170
|
-
radius="md"
|
|
171
|
-
leftSection={showWalletCode ? <IconChevronUp size={14} /> : <IconChevronDown size={14} />}
|
|
172
|
-
onClick={() => setShowWalletCode(!showWalletCode)}
|
|
173
|
-
>
|
|
174
|
-
{showWalletCode ? 'Hide' : 'View'} Implementation
|
|
175
|
-
</Button>
|
|
176
|
-
{showWalletCode && (
|
|
177
|
-
<ActionIcon variant="subtle" color="gray" size="sm" radius="md" onClick={() => copyToClipboard(walletCodeExample)}>
|
|
178
|
-
<IconCopy size={14} />
|
|
179
|
-
</ActionIcon>
|
|
180
|
-
)}
|
|
181
|
-
</Group>
|
|
182
|
-
|
|
183
|
-
<Collapse in={showWalletCode}>
|
|
184
|
-
<Paper mt="sm" p="md" bg="gray.0" radius="md" withBorder>
|
|
185
|
-
<CodeHighlight code={walletCodeExample} language="tsx" withCopyButton={false} expandCodeLabel="" collapseCodeLabel="" />
|
|
186
|
-
</Paper>
|
|
187
|
-
</Collapse>
|
|
188
|
-
</Stack>
|
|
189
|
-
</Card>
|
|
190
|
-
|
|
191
|
-
<Stack gap="lg">
|
|
192
|
-
{/* Balance Example */}
|
|
193
|
-
<Card shadow="xs" p="lg" radius="md" withBorder>
|
|
194
|
-
<Stack gap="md">
|
|
195
|
-
<Flex justify="space-between" align="flex-start">
|
|
196
|
-
<Stack gap="xs">
|
|
197
|
-
<Flex align="center" gap="md">
|
|
198
|
-
<ThemeIcon size={40} radius="md" color="green" variant="light">
|
|
199
|
-
<IconCoins size={20} />
|
|
200
|
-
</ThemeIcon>
|
|
201
|
-
<Title order={3} size="h3" fw={600}>
|
|
202
|
-
Wallet Balance
|
|
203
|
-
</Title>
|
|
204
|
-
</Flex>
|
|
205
|
-
<Text size="sm" c="gray.6">
|
|
206
|
-
Query your wallet's SEI balance using Wagmi's usePublicClient hook
|
|
207
|
-
</Text>
|
|
208
|
-
</Stack>
|
|
209
|
-
<Badge color="green" variant="light" size="md" radius="md">
|
|
210
|
-
balance
|
|
211
|
-
</Badge>
|
|
212
|
-
</Flex>
|
|
213
|
-
<Paper p="md" radius="md" withBorder bg="gray.0">
|
|
214
|
-
<Text size="xs" fw={500} c="gray.6">
|
|
215
|
-
Current Balance
|
|
216
|
-
</Text>
|
|
217
|
-
<Flex justify="space-between" align="center">
|
|
218
|
-
<Flex align="baseline" gap="xs">
|
|
219
|
-
{balance ? (
|
|
220
|
-
<>
|
|
221
|
-
<Text fw={700} size="xl" c="gray.9" ff="monospace">
|
|
222
|
-
{Number.parseFloat(balance).toFixed(4)}
|
|
223
|
-
</Text>
|
|
224
|
-
<Text size="sm" c="gray.6" fw={500}>
|
|
225
|
-
SEI
|
|
226
|
-
</Text>
|
|
227
|
-
</>
|
|
228
|
-
) : (
|
|
229
|
-
<Paper px="sm" py={4} radius="md" withBorder bg="white">
|
|
230
|
-
<Flex align="baseline" gap="xs">
|
|
231
|
-
<Text fw={700} size="xl" c="gray.5" ff="monospace">
|
|
232
|
-
—
|
|
233
|
-
</Text>
|
|
234
|
-
<Text size="sm" c="gray.6" fw={500}>
|
|
235
|
-
SEI
|
|
236
|
-
</Text>
|
|
237
|
-
</Flex>
|
|
238
|
-
</Paper>
|
|
239
|
-
)}
|
|
240
|
-
</Flex>
|
|
241
|
-
<Button
|
|
242
|
-
onClick={getBalanceWagmi}
|
|
243
|
-
disabled={!address}
|
|
244
|
-
size="sm"
|
|
245
|
-
radius="md"
|
|
246
|
-
variant="light"
|
|
247
|
-
color="green"
|
|
248
|
-
leftSection={<IconCoins size={14} />}
|
|
249
|
-
>
|
|
250
|
-
{balance ? 'Refresh' : 'Check Balance'}
|
|
251
|
-
</Button>
|
|
252
|
-
</Flex>
|
|
253
|
-
</Paper>
|
|
254
|
-
|
|
255
|
-
<Group justify="space-between" align="center" mt="sm">
|
|
256
|
-
<Button
|
|
257
|
-
variant="subtle"
|
|
258
|
-
color="gray"
|
|
259
|
-
size="sm"
|
|
260
|
-
radius="md"
|
|
261
|
-
leftSection={showBalanceCode ? <IconChevronUp size={14} /> : <IconChevronDown size={14} />}
|
|
262
|
-
onClick={() => setShowBalanceCode(!showBalanceCode)}
|
|
263
|
-
>
|
|
264
|
-
{showBalanceCode ? 'Hide' : 'View'} Implementation
|
|
265
|
-
</Button>
|
|
266
|
-
{showBalanceCode && (
|
|
267
|
-
<ActionIcon variant="subtle" color="gray" size="sm" radius="md" onClick={() => copyToClipboard(balanceCodeExample)}>
|
|
268
|
-
<IconCopy size={14} />
|
|
269
|
-
</ActionIcon>
|
|
270
|
-
)}
|
|
271
|
-
</Group>
|
|
272
|
-
|
|
273
|
-
<Collapse in={showBalanceCode}>
|
|
274
|
-
<Paper mt="sm" p="md" bg="gray.0" radius="md" withBorder>
|
|
275
|
-
<CodeHighlight code={balanceCodeExample} language="tsx" withCopyButton={false} expandCodeLabel="" collapseCodeLabel="" />
|
|
276
|
-
</Paper>
|
|
277
|
-
</Collapse>
|
|
278
|
-
</Stack>
|
|
279
|
-
</Card>
|
|
280
|
-
|
|
281
|
-
{/* Transaction Example */}
|
|
282
|
-
<Card shadow="xs" p="lg" radius="md" withBorder>
|
|
283
|
-
<Stack gap="md">
|
|
284
|
-
<Flex direction="row" justify="space-between" align="flex-start">
|
|
285
|
-
<Stack gap="xs">
|
|
286
|
-
<Flex direction="row" align="center" gap="md" mb="md">
|
|
287
|
-
<ThemeIcon size={40} radius="md" color="blue" variant="light">
|
|
288
|
-
<IconSend size={20} />
|
|
289
|
-
</ThemeIcon>
|
|
290
|
-
<Title order={3} size="h3" fw={600} c="gray.9">
|
|
291
|
-
Send Transaction
|
|
292
|
-
</Title>
|
|
293
|
-
</Flex>
|
|
294
|
-
<Text c="gray.6" size="sm" maw={400}>
|
|
295
|
-
Send SEI tokens using Wagmi's transaction hooks with real-time status
|
|
296
|
-
</Text>
|
|
297
|
-
</Stack>
|
|
298
|
-
<Badge color="blue" variant="light" size="md" radius="md">
|
|
299
|
-
transfer
|
|
300
|
-
</Badge>
|
|
301
|
-
</Flex>
|
|
302
|
-
<Paper p="md" radius="md" withBorder bg="gray.0">
|
|
303
|
-
<Flex align="flex-end" gap="sm">
|
|
304
|
-
<Flex flex={1} direction="column">
|
|
305
|
-
<Text size="xs" fw={500} c="gray.6" mb={4}>
|
|
306
|
-
Recipient Address
|
|
307
|
-
</Text>
|
|
308
|
-
<TextInput placeholder="0x..." value={recipient} onChange={(e) => setRecipient(e.currentTarget.value)} radius="md" size="md" />
|
|
309
|
-
</Flex>
|
|
310
|
-
<Flex w={128} direction="column">
|
|
311
|
-
<Text size="xs" fw={500} c="gray.6" mb={4}>
|
|
312
|
-
Amount
|
|
313
|
-
</Text>
|
|
314
|
-
<TextInput
|
|
315
|
-
placeholder="0.1"
|
|
316
|
-
value={amount}
|
|
317
|
-
onChange={(e) => setAmount(e.currentTarget.value)}
|
|
318
|
-
radius="md"
|
|
319
|
-
size="md"
|
|
320
|
-
rightSection={
|
|
321
|
-
<Text size="xs" c="gray.6" fw={500} pr="xs">
|
|
322
|
-
SEI
|
|
323
|
-
</Text>
|
|
324
|
-
}
|
|
325
|
-
/>
|
|
326
|
-
</Flex>
|
|
327
|
-
<Button
|
|
328
|
-
onClick={sendSei}
|
|
329
|
-
disabled={isPending || !address || !recipient || !amount}
|
|
330
|
-
size="md"
|
|
331
|
-
radius="md"
|
|
332
|
-
variant="light"
|
|
333
|
-
color="blue"
|
|
334
|
-
px="sm"
|
|
335
|
-
>
|
|
336
|
-
{isPending ? <Loader size={16} /> : <IconSend size={16} />}
|
|
337
|
-
</Button>
|
|
338
|
-
</Flex>
|
|
339
|
-
</Paper>
|
|
340
|
-
|
|
341
|
-
{hash && (
|
|
342
|
-
<Alert color="blue" variant="light" radius="md" py={4}>
|
|
343
|
-
<Stack gap={4}>
|
|
344
|
-
<Text size="xs" fw={600}>
|
|
345
|
-
Transaction Hash
|
|
346
|
-
</Text>
|
|
347
|
-
<Code>{hash}</Code>
|
|
348
|
-
</Stack>
|
|
349
|
-
</Alert>
|
|
350
|
-
)}
|
|
351
|
-
|
|
352
|
-
{isConfirming && (
|
|
353
|
-
<Alert color="yellow" variant="light" radius="md" py={4}>
|
|
354
|
-
<Group gap="xs">
|
|
355
|
-
<Loader size={14} />
|
|
356
|
-
<Text size="xs" fw={500}>
|
|
357
|
-
Waiting for confirmation...
|
|
358
|
-
</Text>
|
|
359
|
-
</Group>
|
|
360
|
-
</Alert>
|
|
361
|
-
)}
|
|
362
|
-
|
|
363
|
-
{isConfirmed && (
|
|
364
|
-
<Alert color="green" variant="light" radius="md" py={4}>
|
|
365
|
-
<Text size="xs" fw={600}>
|
|
366
|
-
✅ Transaction confirmed!
|
|
367
|
-
</Text>
|
|
368
|
-
</Alert>
|
|
369
|
-
)}
|
|
370
|
-
|
|
371
|
-
<Group justify="space-between" align="center" mt={8}>
|
|
372
|
-
<Button
|
|
373
|
-
variant="subtle"
|
|
374
|
-
color="gray"
|
|
375
|
-
size="sm"
|
|
376
|
-
radius="xl"
|
|
377
|
-
leftSection={showTransactionCode ? <IconChevronUp size={14} /> : <IconChevronDown size={14} />}
|
|
378
|
-
onClick={() => setShowTransactionCode(!showTransactionCode)}
|
|
379
|
-
>
|
|
380
|
-
{showTransactionCode ? 'Hide' : 'View'} Implementation
|
|
381
|
-
</Button>
|
|
382
|
-
{showTransactionCode && (
|
|
383
|
-
<ActionIcon variant="subtle" color="gray" size="sm" radius="xl" onClick={() => copyToClipboard(transactionCodeExample)}>
|
|
384
|
-
<IconCopy size={14} />
|
|
385
|
-
</ActionIcon>
|
|
386
|
-
)}
|
|
387
|
-
</Group>
|
|
388
|
-
|
|
389
|
-
<Collapse in={showTransactionCode}>
|
|
390
|
-
<Paper mt="sm" p="md" bg="gray.0" radius="md" withBorder>
|
|
391
|
-
<CodeHighlight code={transactionCodeExample} language="tsx" withCopyButton={false} expandCodeLabel="" collapseCodeLabel="" />
|
|
392
|
-
</Paper>
|
|
393
|
-
</Collapse>
|
|
394
|
-
</Stack>
|
|
395
|
-
</Card>
|
|
396
|
-
</Stack>
|
|
397
|
-
</Stack>
|
|
398
|
-
</Container>
|
|
399
|
-
);
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
export default Examples;
|